diff options
author | Raúl Benencia <rbenencia@linti.unlp.edu.ar> | 2012-08-02 22:51:17 -0300 |
---|---|---|
committer | Raúl Benencia <rbenencia@linti.unlp.edu.ar> | 2012-08-02 22:51:17 -0300 |
commit | 9d13223e971c1bb37b141cb0b0a3a7dd4077f4d8 (patch) | |
tree | e5894afd118054f58d6dd19cc95bb8db93208ed0 /model.py | |
parent | ee504272d535dcfab2d00948a1b005b87dc6605a (diff) |
Fix various semantic errors
Diffstat (limited to 'model.py')
-rw-r--r-- | model.py | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -1,4 +1,4 @@ -from xml.etree import ElementTree +from xml.etree.ElementTree import ElementTree class Network(): """A simple network definition""" @@ -37,9 +37,9 @@ class Data(): def __init__(self, config): self.config = config - self.networks = [] - self.domains = [] - self.persons = [] + self.networks = None + self.domains = None + self.persons = None def parse_config(self): """Parse neccesary config params depending on the method used @@ -79,7 +79,7 @@ class Data(): return self.persons -class DataXML(model.Data): +class DataXML(Data): """Reads network information from a XML file""" def parse_config(self): @@ -90,8 +90,13 @@ class DataXML(model.Data): def load_data(self): """Parse XML for getting network information""" + self.parse_config() root = ElementTree(file=self.data_file).getroot() + self.networks = {} + self.domains = {} + self.persons = {} + for elem in root: if elem.tag == 'person': self.add_person(elem) @@ -105,7 +110,7 @@ class DataXML(model.Data): def add_person(self, elem): """Adds a new person""" - person = model.Person() + person = Person() for e in elem: if e.tag == 'name': person.name = e.text @@ -121,7 +126,7 @@ class DataXML(model.Data): def add_domain(self, elem): """Adds a new domain""" - domain = model.Domain() + domain = Domain() for e in elem: if e.tag == 'name': domain.name == e.text @@ -133,7 +138,7 @@ class DataXML(model.Data): def add_network(self, elem): """Adds a new network""" - network = model.Network() + network = Network() for e in elem: if e.tag == 'name': network.name = e.text |