From a5b40805829252dadc4cc45fe2b91a8d53cd14d0 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 7 Oct 2015 01:04:40 +0000 Subject: 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 --- rpki/xml_utils.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'rpki/xml_utils.py') 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. -- cgit v1.2.3