diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-09-12 13:59:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 13:59:18 +0100 |
commit | 205d957d092ade5708cc2182381864c04e4c0aff (patch) | |
tree | e78636efaa1332c5d49e1c2f023721dc030f8d6a /python/vyos/utils | |
parent | 9652bfda0a7f3e7932aecb32262c34f3fede72b2 (diff) | |
parent | eaa9c82670fa5ee90835266e6f7a24f81c49d17e (diff) | |
download | vyos-1x-205d957d092ade5708cc2182381864c04e4c0aff.tar.gz vyos-1x-205d957d092ade5708cc2182381864c04e4c0aff.zip |
Merge pull request #4050 from jestabro/revise-migration-circinus
T6007: revise migration system
Diffstat (limited to 'python/vyos/utils')
-rw-r--r-- | python/vyos/utils/dict.py | 2 | ||||
-rw-r--r-- | python/vyos/utils/system.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/python/vyos/utils/dict.py b/python/vyos/utils/dict.py index 9a4671c5f..1a7a6b96f 100644 --- a/python/vyos/utils/dict.py +++ b/python/vyos/utils/dict.py @@ -34,7 +34,7 @@ def colon_separated_to_dict(data_string, uniquekeys=False): otherwise they are always lists of strings. """ import re - key_value_re = re.compile('([^:]+)\s*\:\s*(.*)') + key_value_re = re.compile(r'([^:]+)\s*\:\s*(.*)') data_raw = re.split('\n', data_string) diff --git a/python/vyos/utils/system.py b/python/vyos/utils/system.py index 55813a5f7..cfd5b142c 100644 --- a/python/vyos/utils/system.py +++ b/python/vyos/utils/system.py @@ -98,3 +98,15 @@ def load_as_module(name: str, path: str): mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) return mod + +def load_as_module_source(name: str, path: str): + """ Necessary modification of load_as_module for files without *.py + extension """ + import importlib.util + from importlib.machinery import SourceFileLoader + + loader = SourceFileLoader(name, path) + spec = importlib.util.spec_from_loader(name, loader) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod |