[elbe-devel] [PATCH 1/6] treeutils: add bool_attr() method to elem
Torben Hohn
torben.hohn at linutronix.de
Wed Dec 19 17:01:59 CET 2018
To parse boolean attributes, some logic is necessary.
Add the necessary method to the elem class.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/treeutils.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
index 8ba635d8..0caea6d5 100644
--- a/elbepack/treeutils.py
+++ b/elbepack/treeutils.py
@@ -104,6 +104,15 @@ class elem(ebase):
def remove_child(self, child):
self.et.remove(child.et)
+ def bool_attr(self, attrname):
+ attr = self.et.attrib.get(attrname)
+ if attr is None:
+ return False
+ elif attr in ['true', '1']:
+ return True
+ elif attr in ['false', '0']:
+ return False
+
class etree(ebase):
def __init__(self, fname):
--
2.11.0
More information about the elbe-devel
mailing list