[elbe-devel] [PATCH 1/6] treeutils: add bool_attr() method to elem
Manuel Traut
manut at linutronix.de
Fri Dec 21 10:01:49 CET 2018
On 17:01 Wed 19 Dec , Torben Hohn wrote:
> 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>
Reviewed-by: Manuel Traut <manut 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
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
More information about the elbe-devel
mailing list