summaryrefslogtreecommitdiff
path: root/model.py
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2012-08-03 15:53:33 -0300
committerRaúl Benencia <rul@kalgan.cc>2012-08-03 15:53:33 -0300
commit9ca5c7e07f1e5ab4a28c042a72a7f9f29b3426c5 (patch)
treea457b8168fc6c623c97792e474d97b7ff95e50c4 /model.py
parent21ac58f5dabc78a8c7bb56249f5fa0151202e3d0 (diff)
Search by domain
Diffstat (limited to 'model.py')
-rw-r--r--model.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/model.py b/model.py
index 99f368f..ef5ce28 100644
--- a/model.py
+++ b/model.py
@@ -10,6 +10,29 @@ class Network():
self.ip_blocks = []
self.data = {}
+ def as_dict(self, data):
+ # Beautify
+ result = {}
+ domains = data.get_domains()
+ persons = data.get_persons()
+
+ result['name'] = self.name
+
+ # Domains
+ result['domains'] = []
+ for d in self.domains:
+ result['domains'].append(domains[d])
+
+ # Admins
+ result['admins'] = []
+ for a in self.admins:
+ result['admins'].append(persons[a])
+
+ # Networks
+ result['networks'] = self.ip_blocks
+
+ return result
+
class Domain():
"""A simple domain definition"""
@@ -121,6 +144,7 @@ class DataXML(Data):
else:
person.data[e.tag] = e.text
+ print("[+] Read person: {0} - {1} - {2}".format(person.name, person.surname, person.email))
self.persons[elem.attrib['id']] = person
def add_domain(self, elem):
@@ -129,10 +153,11 @@ class DataXML(Data):
domain = Domain()
for e in elem:
if e.tag == 'name':
- domain.name == e.text
+ domain.name = e.text
else:
domain.data[e.tag] = e.text
+ print("[+] Read domain: {}".format(domain.name))
self.domains[elem.attrib['id']] = domain
def add_network(self, elem):
nihil fit ex nihilo