equal
deleted
inserted
replaced
8 from lxml import etree |
8 from lxml import etree |
9 import util.paths as paths |
9 import util.paths as paths |
10 from plcopen.structures import StdBlckLibs |
10 from plcopen.structures import StdBlckLibs |
11 |
11 |
12 ScriptDirectory = paths.AbsDir(__file__) |
12 ScriptDirectory = paths.AbsDir(__file__) |
|
13 |
13 |
14 |
14 class XSLTModelQuery(object): |
15 class XSLTModelQuery(object): |
15 """ a class to handle XSLT queries on project and libs """ |
16 """ a class to handle XSLT queries on project and libs """ |
16 def __init__(self, controller, xsltpath, ext = []): |
17 def __init__(self, controller, xsltpath, ext = []): |
17 # arbitrary set debug to false, updated later |
18 # arbitrary set debug to false, updated later |
37 def _process_xslt(self, root, debug, **kwargs): |
38 def _process_xslt(self, root, debug, **kwargs): |
38 self.debug = debug |
39 self.debug = debug |
39 res = self.xslt(root,**{k:etree.XSLT.strparam(v) for k,v in kwargs.iteritems()}) |
40 res = self.xslt(root,**{k:etree.XSLT.strparam(v) for k,v in kwargs.iteritems()}) |
40 # print(self.xslt.error_log) |
41 # print(self.xslt.error_log) |
41 return res |
42 return res |
|
43 |
|
44 |
|
45 # ------------------------------------------------------------------------------- |
|
46 # Helpers functions for translating list of arguments |
|
47 # from xslt to valid arguments |
|
48 # ------------------------------------------------------------------------------- |
|
49 |
|
50 |
|
51 def _StringValue(x): |
|
52 return x |
|
53 |
|
54 |
|
55 def _BoolValue(x): |
|
56 return x in ["true", "0"] |
|
57 |
|
58 |
|
59 def _translate_args(translations, args): |
|
60 return [translate(arg[0]) if len(arg) > 0 else None |
|
61 for translate, arg in |
|
62 zip(translations, args)] |
|
63 |