import xml.dom.minidom
class Municipios:
- def __init__(self, UF):
- self.xml = xml.dom.minidom.parse("res/%s.xml" % (UF,))
+ def __init__(self):
self.l = []
- self._list()
def _list(self):
for i in self.xml.childNodes[0].childNodes:
return i
return None
+ def carregar_estado(self, UF):
+ self.l = []
+ self.xml = xml.dom.minidom.parse("res/%s.xml" % (UF,))
+ self._list()
+
def verify_cep(self, m, cep):
l = m[2][0:7]
h = m[2][9:16]
return False
if __name__ == '__main__':
- municipios = Municipios('MG')
+ municipios = Municipios()
+
+ municipios.carregar_estado('MG')
m = municipios.get_municipio('4877')
print m[1]
print municipios.verify_cep(m, '36880000')
print municipios.verify_cep(m, '05020000')
- municipios = Municipios('SP')
+ municipios.carregar_estado('SP')
m = municipios.get_municipio('7107')
print m[1]
print municipios.verify_cep(m, '05020000')