summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-11-18 13:42:08 +0000
committerGitHub <noreply@github.com>2022-11-18 13:42:08 +0000
commit97056cad18664bea06310d59e8a769add077f6d0 (patch)
tree7fe5078144c074a447aec93831c8ec493f436ecb /python/vyos/util.py
parent0094bdfd15b4732a4be417f1777e903a41a8a954 (diff)
parentb8bda7c8d54fb500716c78ca39107e33988311ea (diff)
downloadvyos-1x-97056cad18664bea06310d59e8a769add077f6d0.tar.gz
vyos-1x-97056cad18664bea06310d59e8a769add077f6d0.zip
Merge pull request #1662 from jestabro/config-script-dependency
firewall: T4821: correct calling of conf_mode script dependencies
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r--python/vyos/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index a80584c5a..9ebe69b6c 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -1143,3 +1143,11 @@ def camel_to_snake_case(name: str) -> str:
pattern = r'\d+|[A-Z]?[a-z]+|\W|[A-Z]{2,}(?=[A-Z][a-z]|\d|\W|$)'
words = re.findall(pattern, name)
return '_'.join(map(str.lower, words))
+
+def load_as_module(name: str, path: str):
+ import importlib.util
+
+ spec = importlib.util.spec_from_file_location(name, path)
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
+ return mod