X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=src%2Fbens.py;h=0ad051b240a671ec3800d266727a2c804475c636;hb=eb6f8f6e556200c09e7d3d3597eb4a4ea1378102;hp=a098e7925559508eea40fe446c8f06e7cfec6b2c;hpb=5765b0ac2e31ba7281ddfd5aa33c600d2f0ff944;p=cascardo%2Firpf-gui.git diff --git a/src/bens.py b/src/bens.py index a098e79..0ad051b 100644 --- a/src/bens.py +++ b/src/bens.py @@ -1,3 +1,4 @@ +# coding=utf-8 # # Copyright 2013 Thadeu Lima de Souza Cascardo # @@ -14,48 +15,43 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -*- mode: python; encoding: utf-8; -*- -import xml.dom.minidom -from contribuinte import Contribuinte - -class Bem: - def __init__(self, el): - self.bem = el - def get_attr(self, attr): - if attr in self.bem.attributes.keys(): - return self.bem.attributes[attr].nodeValue - return None - def set_attr(self, attr, val): - self.bem.attributes[attr].nodeValue = val - -class Bens: - def __init__(self, contribuinte): - self.contribuinte = contribuinte - self.bens = self.contribuinte.dados.getElementsByTagName("bens")[0] - self.items = [] - for i in self.bens.getElementsByTagName("item"): - self.items.append(Bem(i)) - - def _get_attr(self, el, attr): - if attr in el.attributes.keys(): - return el.attributes[attr].nodeValue - return None - - def _set_attr(self, el, attr, val): - el.attributes[attr].nodeValue = val - def get_bens(self, attr): - return self._get_attr(self.bens, attr) +import xml.dom.minidom +import items +from form import AttrForm, TipoForm +import tipos - def set_bens(self, attr, val): - self._set_attr(self.bens, attr, val) +class Bens(items.Items): + def __init__(self, contribuinte): + contribuinte = contribuinte + bens = contribuinte.dados.getElementsByTagName("bens")[0] + items.Items.__init__(self, bens) + def form(self, item): + form = [] + form.append(AttrForm("Nome", "discriminacao", item)) + form.append(AttrForm("Valor Anterior", "valorExercicioAnterior", item)) + form.append(AttrForm("Valor Atual", "valorExercicioAtual", item)) + form.append(BensForm(item)) + return form + +class tipoBens(tipos.Tipos): + def __init__(self): + tipos.Tipos.__init__(self, "tipoBens.xml", ["COL1", "COL2"]) + +class BensForm(TipoForm): + def __init__(self, bem): + TipoForm.__init__(self, "Tipo Bem", "codigo", bem, tipoBens(), (0, 1)) if __name__ == '__main__': import sys - contribuinte = Contribuinte(sys.argv[1]) - bens = Bens(contribuinte) - print "anterior: " + bens.get_bens("totalExercicioAnterior") - print "atual: " + bens.get_bens("totalExercicioAtual") - for i in bens.items: - print i.get_attr("valorExercicioAtual") + " " + i.get_attr("discriminacao") + from contribuinte import Contribuinte + + contribuinte = Contribuinte(sys.argv[1]) + bens = Bens(contribuinte) + print "anterior: " + bens.get_attr("totalExercicioAnterior") + print "atual: " + bens.get_attr("totalExercicioAtual") + + for i in bens.items: + print i.get_attr("valorExercicioAtual") + " " + i.get_attr("discriminacao") # vim:tabstop=4:expandtab:smartindent