projects
/
zonemaker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
aa7f756
)
fix for python 3.2
author
Ralf Jung
<post@ralfj.de>
Tue, 11 Nov 2014 10:18:07 +0000
(11:18 +0100)
committer
Ralf Jung
<post@ralfj.de>
Tue, 11 Nov 2014 10:18:07 +0000
(11:18 +0100)
zone-maker
patch
|
blob
|
history
zonemaker/zone.py
patch
|
blob
|
history
diff --git
a/zone-maker
b/zone-maker
index 676bf9c1a8559e73040a2f1cb088f7d8acf1972f..4a02e17d85ead5a6bd0c7328d5c3b33b124db570 100755
(executable)
--- a/
zone-maker
+++ b/
zone-maker
@@
-4,11
+4,17
@@
from zonemaker.zone import Zone
#import typing
def load_module(name, path, write_bytecode = False):
#import typing
def load_module(name, path, write_bytecode = False):
- import importlib.machinery
old_val = sys.dont_write_bytecode
sys.dont_write_bytecode = not write_bytecode
old_val = sys.dont_write_bytecode
sys.dont_write_bytecode = not write_bytecode
- module = importlib.machinery.SourceFileLoader(name, path).load_module()
- sys.dont_write_bytecode = old_val
+ module = None
+ try:
+ from importlib.machinery import SourceFileLoader
+ module = SourceFileLoader(name, path).load_module()
+ except ImportError:
+ import imp
+ module = imp.load_source(name, path)
+ finally:
+ sys.dont_write_bytecode = old_val
return module
def make_zone(filename: str) -> None:
return module
def make_zone(filename: str) -> None:
diff --git
a/zonemaker/zone.py
b/zonemaker/zone.py
index 4da0906cb3bdb7490430689b929b65733326c2ea..094c0f868eee8fe19c6dc1fa4f583dfc6b3326e6 100644
(file)
--- a/
zonemaker/zone.py
+++ b/
zonemaker/zone.py
@@
-13,12
+13,14
@@
REGEX_ipv4 = r'^\d{1,3}(\.\d{1,3}){3}$'
REGEX_ipv6 = r'^[a-fA-F0-9]{1,4}(:[a-fA-F0-9]{1,4}){7}$'
def check_label(label: str) -> str:
REGEX_ipv6 = r'^[a-fA-F0-9]{1,4}(:[a-fA-F0-9]{1,4}){7}$'
def check_label(label: str) -> str:
+ label = str(label)
pattern = r'^{0}$'.format(REGEX_label)
if re.match(pattern, label):
return label
raise Exception(label+" is not a valid label")
def check_hostname(name: str) -> str:
pattern = r'^{0}$'.format(REGEX_label)
if re.match(pattern, label):
return label
raise Exception(label+" is not a valid label")
def check_hostname(name: str) -> str:
+ name = str(name)
# check hostname for validity
pattern = r'^{0}(\.{0})*\.?$'.format(REGEX_label)
if re.match(pattern, name):
# check hostname for validity
pattern = r'^{0}(\.{0})*\.?$'.format(REGEX_label)
if re.match(pattern, name):
@@
-26,16
+28,19
@@
def check_hostname(name: str) -> str:
raise Exception(name+" is not a valid hostname")
def check_hex(data: str) -> str:
raise Exception(name+" is not a valid hostname")
def check_hex(data: str) -> str:
+ data = str(data)
if re.match('^[a-fA-F0-9]+$', data):
return data
raise Exception(data+" is not valid hex data")
def check_ipv4(address: str) -> str:
if re.match('^[a-fA-F0-9]+$', data):
return data
raise Exception(data+" is not valid hex data")
def check_ipv4(address: str) -> str:
+ address = str(address)
if re.match(REGEX_ipv4, address):
return address
raise Exception(address+" is not a valid IPv4 address")
def check_ipv6(address: str) -> str:
if re.match(REGEX_ipv4, address):
return address
raise Exception(address+" is not a valid IPv4 address")
def check_ipv6(address: str) -> str:
+ address = str(address)
if re.match(REGEX_ipv6, address):
return address
raise Exception(address+" is not a valid IPv6 address")
if re.match(REGEX_ipv6, address):
return address
raise Exception(address+" is not a valid IPv6 address")