# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -*- mode: python; encoding: utf-8; -*-
+
import xml.dom.minidom
import dirs
+import tipos
-class Ocupacoes:
+class Ocupacoes(tipos.Tipos):
def __init__(self):
- irpf_dir = dirs.get_default_irpf_dir()
- self.xml = xml.dom.minidom.parse(irpf_dir.get_resource_file("ocupacoesPrincipal.xml"))
- self.l = []
- self.g = {}
- self._list()
- self._group()
-
- def _list(self):
- for i in self.xml.getElementsByTagName("ITEM"):
- if "COL4" in i.attributes.keys():
- self.l.append((i.attributes["COL1"].nodeValue, \
- i.attributes["COL2"].nodeValue, \
- i.attributes["COL3"].nodeValue, \
- i.attributes["COL4"].nodeValue))
-
- def list(self):
- return self.l
-
- def _group(self):
- for i in self.l:
- if i[1] not in self.g:
- self.g[i[1]] = []
- self.g[i[1]].append(i)
-
- def groups(self):
- return self.g
+ tipos.Tipos.__init__(self, "ocupacoesPrincipal.xml", ["COL1", "COL2", "COL3", "COL4"], 1)
def get_ocupacao(self, code):
- for i in self.l:
- if i[0] == code:
- return i
- return None
+ return self.get_by_code(code)
if __name__ == '__main__':
ocupacoes = Ocupacoes()