From 9d13223e971c1bb37b141cb0b0a3a7dd4077f4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Thu, 2 Aug 2012 22:51:17 -0300 Subject: Fix various semantic errors --- model.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'model.py') diff --git a/model.py b/model.py index 13bcfa8..99f368f 100644 --- a/model.py +++ b/model.py @@ -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 -- cgit v1.2.3