Separa declarações e contribuinte.
[cascardo/irpf-gui.git] / src / declaracoes.py
1 # coding=utf-8
2 #
3 #   Copyright 2013-2014 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
4 #
5 #   This program is free software: you can redistribute it and/or modify
6 #   it under the terms of the GNU General Public License as published by
7 #   the Free Software Foundation, either version 3 of the License, or
8 #   (at your option) any later version.
9 #
10 #   This program is distributed in the hope that it will be useful,
11 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #   GNU General Public License for more details.
14 #
15 #   You should have received a copy of the GNU General Public License
16 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 # -*- mode: python; encoding: utf-8; -*-
18
19 import xml.dom.minidom
20 import dirs
21 import os
22 import items
23
24 class Declaracoes(items.Items):
25     def __init__(self):
26         irpf_dir = dirs.get_default_irpf_dir()
27
28         if not os.path.exists(irpf_dir.get_resource_dir()):
29             raise RuntimeError("O caminho para o resource não existe: " + \
30                     irpf_dir.get_resource_dir())
31
32         if not os.path.exists(irpf_dir.get_userdata_dir()):
33             raise RuntimeError("O caminho para os dados não existe: " + \
34                     irpf_dir.get_userdata_dir())
35
36         self.iddecl_file = irpf_dir.get_userdata_file("iddeclaracoes.xml")
37         self.declaracoes = xml.dom.minidom.parse(self.iddecl_file)
38         classe = self.declaracoes.getElementsByTagName("classe")[0]
39         items.Items.__init__(self, classe)
40
41     def save(self):
42         self.declaracoes.writexml(open(self.iddecl_file, "w"))
43
44     attributes = [
45             "dataUltimoAcesso",
46             "declaracaoRetificadora",
47             "enderecoDiferente",
48             "enderecoMACRede",
49             "exercicio",
50             "nome",
51             "numReciboDecRetif",
52             "numeroReciboDecAnterior",
53             "resultadoDeclaracao",
54             "tipoDeclaracao",
55             "tipoDeclaracaoAES",
56             "transmitida",
57             "versaoBeta"
58             ]
59
60 if __name__ == '__main__':
61     import sys
62     dec = Declaracoes()
63
64     for i in dec.items:
65         print i.get_attr("cpf") + " " + i.get_attr("nome")
66
67 # vim:tabstop=4:expandtab:smartindent