aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins
diff options
context:
space:
mode:
authorrumvadim <rumvadim@yandex-team.ru>2022-02-10 16:50:11 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:11 +0300
commit03ed72c7c79029264440f45994a0b30e84919e80 (patch)
tree6c09e58101af1040d0c4526b7bb938fc0ba007cb /build/plugins
parentf96c49839404784ec306cf2b5523a240c63f8eea (diff)
downloadydb-03ed72c7c79029264440f45994a0b30e84919e80.tar.gz
Restoring authorship annotation for <rumvadim@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/plugins')
-rw-r--r--build/plugins/_xsyn_includes.py110
1 files changed, 55 insertions, 55 deletions
diff --git a/build/plugins/_xsyn_includes.py b/build/plugins/_xsyn_includes.py
index 8d33cea2f0..61d34bea3e 100644
--- a/build/plugins/_xsyn_includes.py
+++ b/build/plugins/_xsyn_includes.py
@@ -1,60 +1,60 @@
def get_include_callback():
- """
- .. function: get_include_callback returns function that processes each DOM element to get xsyn include from it, and it's aware of directory with all the xsyns.
-
- :param xsyn_dir directory with xsyns.
- """
- def get_include(element):
- """
- .. function: get_include returns list of includes from this DOM element.
-
- :param element DOM element.
- """
- res = []
- if element.nodeType == element.ELEMENT_NODE and element.nodeName == "parse:include":
- attrs = element.attributes
- for i in xrange(attrs.length):
- attr = attrs.item(i)
- if attr.nodeName == "path":
- include_filename = attr.nodeValue
- res.append(include_filename)
- return res
-
- return get_include
-
-
-def traverse_xsyn(element, on_element):
- """
- .. function: traverse_xsyn traverses element and returns concatenated lists of calling on_element of each element.
-
- :param element element in DOM.
- :param on_element callback on element that returns list of values.
- """
- res = on_element(element)
- for child in element.childNodes:
- child_results = traverse_xsyn(child, on_element)
- res += child_results
- return res
-
-
-def process_xsyn(filepath, on_element):
- """
- .. function: process_xsyn processes xsyn file and return concatenated list of calling on_element on each DOM element.
-
- :param filepath path to xsyn file
- :param on_element callback called on each element in xsyn that returns list of values.
-
- """
-
- # keep a stack of filepathes if on_element calls process_xsyn recursively
- with open(filepath) as xsyn_file:
+ """
+ .. function: get_include_callback returns function that processes each DOM element to get xsyn include from it, and it's aware of directory with all the xsyns.
+
+ :param xsyn_dir directory with xsyns.
+ """
+ def get_include(element):
+ """
+ .. function: get_include returns list of includes from this DOM element.
+
+ :param element DOM element.
+ """
+ res = []
+ if element.nodeType == element.ELEMENT_NODE and element.nodeName == "parse:include":
+ attrs = element.attributes
+ for i in xrange(attrs.length):
+ attr = attrs.item(i)
+ if attr.nodeName == "path":
+ include_filename = attr.nodeValue
+ res.append(include_filename)
+ return res
+
+ return get_include
+
+
+def traverse_xsyn(element, on_element):
+ """
+ .. function: traverse_xsyn traverses element and returns concatenated lists of calling on_element of each element.
+
+ :param element element in DOM.
+ :param on_element callback on element that returns list of values.
+ """
+ res = on_element(element)
+ for child in element.childNodes:
+ child_results = traverse_xsyn(child, on_element)
+ res += child_results
+ return res
+
+
+def process_xsyn(filepath, on_element):
+ """
+ .. function: process_xsyn processes xsyn file and return concatenated list of calling on_element on each DOM element.
+
+ :param filepath path to xsyn file
+ :param on_element callback called on each element in xsyn that returns list of values.
+
+ """
+
+ # keep a stack of filepathes if on_element calls process_xsyn recursively
+ with open(filepath) as xsyn_file:
from xml.dom.minidom import parse
- tree = parse(xsyn_file)
- tree.normalize()
- res = traverse_xsyn(tree, on_element)
- return res
-
-
+ tree = parse(xsyn_file)
+ tree.normalize()
+ res = traverse_xsyn(tree, on_element)
+ return res
+
+
def get_all_includes(filepath):
callback = get_include_callback()
return process_xsyn(filepath, callback)