Index: tests/tools.py |
diff --git a/tests/tools.py b/tests/tools.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28a432b8ed62d96de2437a63dbfae81ed3f496e8 |
--- /dev/null |
+++ b/tests/tools.py |
@@ -0,0 +1,26 @@ |
+# This Source Code Form is subject to the terms of the Mozilla Public |
+# License, v. 2.0. If a copy of the MPL was not distributed with this |
+# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
+ |
+import os |
+import shutil |
+ |
+ |
+def get_leafs_string(tree): |
+ """Recursively builds a string, representing the path to all leaf-nodes""" |
+ root_str = '{}|{}|{}'.format(tree.tag, tree.tail, tree.text).strip() |
+ result = [] |
+ |
+ if len(tree) > 0: |
+ for subtree in tree: |
+ for leaf in get_leafs_string(subtree): |
+ result.append('{}__{}'.format(root_str, leaf)) |
+ else: |
+ result.append(root_str) |
+ return result |
+ |
+ |
+def copy_metadata(filename, tmpdir): |
+ path = os.path.join(os.path.dirname(__file__), filename) |
+ destination = str(tmpdir.join(filename)) |
+ shutil.copy(path, destination) |