equal
deleted
inserted
replaced
1 #!/usr/bin/env python |
1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- |
2 # -*- coding: utf-8 -*- |
3 # This file is part of Beremiz. |
3 # This file is part of Beremiz. |
4 # See COPYING file for copyrights details. |
4 # See COPYING file for copyrights details. |
5 |
5 |
6 from __future__ import absolute_import |
6 |
7 from lxml import etree |
7 from lxml import etree |
8 |
8 |
9 class XSLTransform(object): |
9 class XSLTransform(object): |
10 """ a class to handle XSLT queries on project and libs """ |
10 """ a class to handle XSLT queries on project and libs """ |
11 def __init__(self, xsltpath, xsltext): |
11 def __init__(self, xsltpath, xsltext): |
16 xsltpath, |
16 xsltpath, |
17 etree.XMLParser()), |
17 etree.XMLParser()), |
18 extensions={("beremiz", name): call for name, call in xsltext}) |
18 extensions={("beremiz", name): call for name, call in xsltext}) |
19 |
19 |
20 def transform(self, root, profile_run=False, **kwargs): |
20 def transform(self, root, profile_run=False, **kwargs): |
21 res = self.xslt(root, profile_run=profile_run, **{k: etree.XSLT.strparam(v) for k, v in kwargs.iteritems()}) |
21 res = self.xslt(root, profile_run=profile_run, **{k: etree.XSLT.strparam(v) for k, v in kwargs.items()}) |
22 # print(self.xslt.error_log) |
22 # print(self.xslt.error_log) |
23 return res |
23 return res |
24 |
24 |
25 def get_error_log(self): |
25 def get_error_log(self): |
26 return self.xslt.error_log |
26 return self.xslt.error_log |