fix node.base to macro file

while parsing macros
This commit is contained in:
Matthias Bernt
2022-01-26 09:50:59 +01:00
committed by mvdbeek
parent 5ea6253e65
commit b7ef626fdf
+8
View File
@@ -283,6 +283,14 @@ def _imported_macro_paths_from_el(macros_el):
def _load_macro_file(path, xml_base_dir):
tree = parse_xml(path, strip_whitespace=False)
for node in tree.iter():
# little hack: node.base contains that path to the file which is used in
# the linter. it is a property that apparently is determined from the
# xmltree, so if the macro is inserted into the main xml node.base will
# give the path of the main xml file.
# luckily lxml allows to set the property:
# https://github.com/lxml/lxml/blob/5a5c7fb01d15af58def4bab2ba7b15c937042835/src/lxml/etree.pyx#L1106
node.base = node.base
root = tree.getroot()
return _load_macros(root, xml_base_dir)