From 15a478566c373cf16c0d88bd34d7441f3dda0092 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Fri, 3 May 2013 22:23:36 -0300 Subject: [PATCH] Bens: suporte inicial Le lista de bens da declaracao, incluindo descricao e valores. --- bens.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bens.py diff --git a/bens.py b/bens.py new file mode 100644 index 0000000..e47a454 --- /dev/null +++ b/bens.py @@ -0,0 +1,55 @@ +# +# Copyright 2013 Thadeu Lima de Souza Cascardo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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) + def set_bens(self, attr, val): + self._set_attr(self.bens, attr, val) + +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") -- 2.20.1