diff options
author | Raúl Benencia <rul@kalgan.cc> | 2012-10-09 15:58:34 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2012-10-09 15:58:34 -0300 |
commit | b3fcf3b4e9dc49b0736e8ba1dfdab2e225999c6d (patch) | |
tree | d7e0a40b8554f792137e4ebb166f2be50d379406 /lib/model.py | |
parent | 9866dfb204b8bdbb5bf341204371a4e4e458a9c4 (diff) |
Done some refactoring. Now values are printed in order
Diffstat (limited to 'lib/model.py')
-rw-r--r-- | lib/model.py | 20 |
1 files changed, 10 insertions, 10 deletions
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 |