aboutsummaryrefslogtreecommitdiff
path: root/rpki/xml_utils.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-10-07 01:04:40 +0000
committerRob Austein <sra@hactrn.net>2015-10-07 01:04:40 +0000
commita5b40805829252dadc4cc45fe2b91a8d53cd14d0 (patch)
treebe048d4d8a7332db07732c3a9aaa3904a1fa3ae0 /rpki/xml_utils.py
parent5600ad7641c6c7084e1ebb849553b93aefa75311 (diff)
Move all the special-case glorp for attribute types into templates,
thereby eliminating still more parsing code. No clue why we didn't do this years ago. svn path=/branches/tk705/; revision=6095
Diffstat (limited to 'rpki/xml_utils.py')
-rw-r--r--rpki/xml_utils.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/rpki/xml_utils.py b/rpki/xml_utils.py
index 89a9095f..b85a60c5 100644
--- a/rpki/xml_utils.py
+++ b/rpki/xml_utils.py
@@ -73,7 +73,9 @@ class base_elt(object):
val = elt.get(key, None)
if val is not None:
val = val.encode("ascii")
- if val.isdigit() and not key.endswith("_handle"):
+ if isinstance(self.attributes, dict) and self.attributes[key] is not None:
+ val = self.attributes[key](val)
+ elif val.isdigit() and not key.endswith("_handle"):
val = long(val)
setattr(self, key, val)
for key in self.booleans:
@@ -110,14 +112,6 @@ class base_elt(object):
Template-driven attribute reader.
"""
- for key in self.attributes:
- val = attrs.get(key, None)
- if isinstance(val, str) and val.isdigit() and not key.endswith("_handle"):
- val = long(val)
- setattr(self, key, val)
- for key in self.booleans:
- setattr(self, key, attrs.get(key, False))
-
def make_elt(self):
"""
XML element constructor.