-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model.py
42 lines (32 loc) · 1.17 KB
/
Model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Controller
# eh- This isn't natual. I'll change this later :p
class OrgRecord(object):
def __init__(self, ip):
self.ip = ip
self._asn = Controller.getAS(self.ip)
self._org = Controller.getLocation(self.ip)
for k, v in zip( ('_locid',
'country',
'region',
'city',
'postalCode',
'latitude',
'longitude',
'metroCode',
'areaCode'),
self._org ):
self.__setattr__(k, v)
if self._asn.startswith('AS'):
self.asnum, self.orgname = self._asn.split(' ', 1)
else:
self.asnum, self.orgname = ('', '')
def __iter__(self):
self._iters = [i for i in dir(self) if not i.startswith('_')]
# Dont need to iter over the next() method
self._iters.remove('next')
return self
def next(self):
if len(self._iters) == 0:
raise StopIteration
_key = self._iters.pop(0)
return (_key, getattr(self, _key))