[elbe-devel] [PATCH 1/2] Handle XML includes
Benedikt Spranger
b.spranger at linutronix.de
Wed Feb 22 18:27:13 CET 2017
Add recognizion of Xincludes in E.L.B.E. XML recipes.
Signed-off-by: Benedikt Spranger <b.spranger at linutronix.de>
---
elbepack/soapclient.py | 33 +++++++++++++++++++--------------
elbepack/treeutils.py | 5 +++--
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index bc38a61..eeee328 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -20,6 +20,11 @@
from __future__ import print_function
+try:
+ from cStringIO import StringIO
+except:
+ from StringIO import StringIO
+
import binascii
from suds.client import Client
from urllib2 import URLError
@@ -233,26 +238,26 @@ class SetXmlAction(ClientAction):
size = 1024 * 1024
part = 0
- with file (filename, "r") as fp:
- while (True):
- xml_base64 = binascii.b2a_base64(fp.read (size))
- # finish upload
- if len (xml_base64) == 1:
- part = client.service.upload_file (builddir,
+ fp = StringIO(x.xml.tostring())
+ while (True):
+ xml_base64 = binascii.b2a_base64(fp.read (size))
+ # finish upload
+ if len (xml_base64) == 1:
+ part = client.service.upload_file (builddir,
"source.xml",
xml_base64,
-1)
- else:
- part = client.service.upload_file (builddir,
+ else:
+ part = client.service.upload_file (builddir,
"source.xml",
xml_base64,
part)
- if part == -1:
- print ("project busy, upload not allowed")
- return part
- if part == -2:
- print ("upload of xml finished")
- return 0
+ if part == -1:
+ print ("project busy, upload not allowed")
+ return part
+ if part == -2:
+ print ("upload of xml finished")
+ return 0
ClientAction.register(SetXmlAction)
diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
index 64b04a0..a4bcf77 100644
--- a/elbepack/treeutils.py
+++ b/elbepack/treeutils.py
@@ -17,7 +17,7 @@
# along with ELBE. If not, see <http://www.gnu.org/licenses/>.
from lxml.etree import ElementTree, SubElement, Element
-from lxml.etree import XMLParser,parse
+from lxml.etree import XMLParser,parse,tostring
import copy
# ElementTree helpers
@@ -117,6 +117,7 @@ class etree(ebase):
if not fname is None:
parser = XMLParser(huge_tree=True, remove_comments=False)
et = parse (fname, parser=parser)
+ et.xinclude()
else:
et = ElementTree( file=None )
@@ -128,7 +129,7 @@ class etree(ebase):
self.et.write(fname, encoding=encoding)
def tostring (self):
- return self.et.tostring ()
+ return tostring( self.et )
def ensure_child( self, tag ):
retval = self.et.find("./"+tag)
--
2.11.0
More information about the elbe-devel
mailing list