From b3fcf3b4e9dc49b0736e8ba1dfdab2e225999c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Tue, 9 Oct 2012 15:58:34 -0300 Subject: Done some refactoring. Now values are printed in order --- lib/model.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/model.py') diff --git a/lib/model.py b/lib/model.py index 933d901..1d1c605 100644 --- a/lib/model.py +++ b/lib/model.py @@ -1,6 +1,7 @@ from xml.etree.ElementTree import ElementTree from lib.config import Config +from lib.core import Answer, AnswerValue, AnswerAdminValue class Network(): """A simple network definition""" @@ -12,26 +13,25 @@ class Network(): self.ip_blocks = [] self.data = {} - def as_dict(self, data): + def as_answer(self, data): # Beautify - result = {} + result = Answer() domains = data.get_domains() persons = data.get_persons() - result['name'] = self.name + result.add_value(AnswerValue(0, 'Name', self.name)) # Domains - result['domains'] = [] for d in self.domains: - result['domains'].append(domains[d]) + result.add_value(AnswerValue(1, 'Domain', domains[d].name)) + + # Networks + for block in self.ip_blocks: + result.add_value(AnswerValue(1, 'Network', block)) # Admins - result['admins'] = [] for a in self.admins: - result['admins'].append(persons[a]) - - # Networks - result['networks'] = self.ip_blocks + result.add_value(AnswerAdminValue(2, persons[a])) return result -- cgit v1.2.3