projects
/
zonemaker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2fd3698
)
parse IP addresses
author
Ralf Jung
<post@ralfj.de>
Sat, 8 Nov 2014 21:29:28 +0000
(22:29 +0100)
committer
Ralf Jung
<post@ralfj.de>
Sat, 8 Nov 2014 21:29:28 +0000
(22:29 +0100)
zone-maker
patch
|
blob
|
history
zonemaker/zone.py
patch
|
blob
|
history
diff --git
a/zone-maker
b/zone-maker
index ddfb19516ae7e65a054abf4fcb886dc8911f4da4..100b17a7932caa0c09568f1b18cb0ee8e7b6fa0e 100755
(executable)
--- a/
zone-maker
+++ b/
zone-maker
@@
-12,7
+12,9
@@
def load_module(name, path, write_bytecode = False):
def make_zone(filename):
zonefile = load_module(os.path.basename(filename), filename)
zones = zonefile.__zones__
def make_zone(filename):
zonefile = load_module(os.path.basename(filename), filename)
zones = zonefile.__zones__
- # TODO do something with the zones
+ # TODO do something more clever with the zones
+ for zone in zones:
+ zone.write(sys.stdout)
if __name__ == "__main__":
for name in sys.argv[1:]:
if __name__ == "__main__":
for name in sys.argv[1:]:
diff --git
a/zonemaker/zone.py
b/zonemaker/zone.py
index 63195050780d58b1581adbf9a6dbdf9749b28c50..5e83854caf68c02833e9229146a3ad41e1b54471 100644
(file)
--- a/
zonemaker/zone.py
+++ b/
zonemaker/zone.py
@@
-1,3
+1,5
@@
+import ipaddress
+
second = 1
minute = 60*second
hour = 60*minute
second = 1
minute = 60*second
hour = 60*minute
@@
-5,8
+7,8
@@
day = 24*hour
class Address:
def __init__(self, IPv4 = None, IPv6 = None):
class Address:
def __init__(self, IPv4 = None, IPv6 = None):
- self._IPv4 =
IPv4
- self._IPv6 =
IPv6
+ self._IPv4 =
None if IPv4 is None else ipaddress.IPv4Address(IPv4)
+ self._IPv6 =
None if IPv6 is None else ipaddress.IPv6Address(IPv6)
def IPv4(self):
return Address(IPv4 = self._IPv4)
def IPv4(self):
return Address(IPv4 = self._IPv4)
@@
-40,3
+42,6
@@
class Zone:
self._NX_TTL = other_TTL if NX_TTL is None else NX_TTL
self._A_TTL = other_TTL if A_TTL is None else A_TTL
self._other_TTL = other_TTL
self._NX_TTL = other_TTL if NX_TTL is None else NX_TTL
self._A_TTL = other_TTL if A_TTL is None else A_TTL
self._other_TTL = other_TTL
+
+ def write(self, file):
+ raise NotImplementedError()