diff options
| author | Christian Breunig <christian@breunig.cc> | 2024-08-26 07:23:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-26 07:23:59 +0200 |
| commit | 42191a8f6a4efc248e973c1bc3a974474835b15e (patch) | |
| tree | 80fa64b91d8a3dcf16e286178433232be5b4f46c /python/vyos/xml_ref/definition.py | |
| parent | da64a7246e9b12d5bd84287517cfbfa59e364c28 (diff) | |
| parent | 9ff620c50625c81733020f399c7f5a14e07c4d09 (diff) | |
| download | veeos-1x-42191a8f6a4efc248e973c1bc3a974474835b15e.tar.gz veeos-1x-42191a8f6a4efc248e973c1bc3a974474835b15e.zip | |
Merge pull request #4015 from jestabro/configdep-prio
T6671: defer config dependency if scheduled in priority queue
Diffstat (limited to 'python/vyos/xml_ref/definition.py')
| -rw-r--r-- | python/vyos/xml_ref/definition.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/python/vyos/xml_ref/definition.py b/python/vyos/xml_ref/definition.py index c85835ffd..5ff28daed 100644 --- a/python/vyos/xml_ref/definition.py +++ b/python/vyos/xml_ref/definition.py @@ -1,4 +1,4 @@ -# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2024 VyOS maintainers and contributors <maintainers@vyos.io> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -139,28 +139,38 @@ class Xml: ref_path = path.copy() d = self.ref data = '' + tag = '' while ref_path and d: + tag_val = '' d = d.get(ref_path[0], {}) ref_path.pop(0) if self._is_tag_node(d) and ref_path: + tag_val = ref_path[0] ref_path.pop(0) if self._is_leaf_node(d) and ref_path: ref_path.pop(0) res = self._get_ref_node_data(d, name) if res is not None: data = res + tag = tag_val - return data + return data, tag - def owner(self, path: list) -> str: + def owner(self, path: list, with_tag=False) -> str: from pathlib import Path - data = self._least_upper_data(path, 'owner') + data, tag = self._least_upper_data(path, 'owner') + tag_ext = f'_{tag}' if tag else '' if data: - data = Path(data.split()[0]).name + if with_tag: + data = Path(data.split()[0]).stem + data = f'{data}{tag_ext}' + else: + data = Path(data.split()[0]).name return data def priority(self, path: list) -> str: - return self._least_upper_data(path, 'priority') + data, _ = self._least_upper_data(path, 'priority') + return data @staticmethod def _dict_get(d: dict, path: list) -> dict: |
