+# coding=utf-8
#
# Copyright 2013 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
#
from contribuinte import Contribuinte
class RendimentoPJ:
- def __init__(self, el):
- self.rendimento = el
+ def __init__(self, el = None):
+ if el == None:
+ self.rendimento = xml.dom.minidom.Element("item")
+ else:
+ self.rendimento = el
def get_attr(self, attr):
if attr in self.rendimento.attributes.keys():
return None
def set_attr(self, attr, val):
- self.rendimento.attributes[attr].nodeValue = val
+ self.rendimento.setAttribute(attr, val)
class RendimentosPJ:
def __init__(self, contribuinte):
def set_colecao(self, attr, val):
self._set_attr(self.colecao, attr, val)
+ def add_item(self, item):
+ self.items.append(item)
+ self.colecao.appendChild(item.rendimento)
+
+ def new_item(self):
+ item = RendimentoPJ()
+ self.add_item(item)
+ return item
+
+ def remove_item(self, i):
+ self.items.pop(i)
+ els = self.colecao.getElementsByTagName("item")
+ self.colecao.removeChild(els[i])
+
if __name__ == '__main__':
import sys