summaryrefslogtreecommitdiff
path: root/python/vyos/utils
diff options
context:
space:
mode:
Diffstat (limited to 'python/vyos/utils')
-rw-r--r--python/vyos/utils/dict.py2
-rw-r--r--python/vyos/utils/system.py13
2 files changed, 13 insertions, 2 deletions
diff --git a/python/vyos/utils/dict.py b/python/vyos/utils/dict.py
index 062ab9c81..1eb6abcd5 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 f427032a4..fca93d118 100644
--- a/python/vyos/utils/system.py
+++ b/python/vyos/utils/system.py
@@ -99,6 +99,18 @@ def load_as_module(name: str, path: str):
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
+
def get_uptime_seconds():
""" Returns system uptime in seconds """
from re import search
@@ -127,4 +139,3 @@ def get_load_averages():
res[15] = float(matches["fifteen"]) / core_count
return res
-