summaryrefslogtreecommitdiff
path: root/obsapi/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'obsapi/helpers.py')
-rw-r--r--obsapi/helpers.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/obsapi/helpers.py b/obsapi/helpers.py
new file mode 100644
index 0000000..6912035
--- /dev/null
+++ b/obsapi/helpers.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+"""
+ obsapi: helper module
+ ~~~~~~~~~~~~~~~~~~~~~
+
+ This module contains helper functions
+
+
+ :copyright: Copyright (c) 2020 Scott Bahling, SUSE Linux GmbH
+ :license: GPL-2.0, see COPYING for details
+"""
+from io import BytesIO
+from lxml import etree
+
+
+def xml2etree(xml):
+ try:
+ if not isinstance(xml, bytes):
+ xml = xml.encode('utf-8')
+ parser = etree.XMLParser(remove_blank_text=True)
+ return etree.parse(BytesIO(xml), parser).xpath('.')[0]
+ except Exception as e:
+ raise e