OLD | NEW |
(Empty) | |
| 1 # This Source Code Form is subject to the terms of the Mozilla Public |
| 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 |
| 5 import os |
| 6 import shutil |
| 7 |
| 8 |
| 9 def get_leafs_string(tree): |
| 10 """Recursively builds a string, representing the path to all leaf-nodes""" |
| 11 root_str = '{}|{}|{}'.format(tree.tag, tree.tail, tree.text).strip() |
| 12 result = [] |
| 13 |
| 14 if len(tree) > 0: |
| 15 for subtree in tree: |
| 16 for leaf in get_leafs_string(subtree): |
| 17 result.append('{}__{}'.format(root_str, leaf)) |
| 18 else: |
| 19 result.append(root_str) |
| 20 return result |
| 21 |
| 22 |
| 23 def copy_metadata(filename, tmpdir): |
| 24 path = os.path.join(os.path.dirname(__file__), filename) |
| 25 destination = str(tmpdir.join(filename)) |
| 26 shutil.copy(path, destination) |
OLD | NEW |