diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/utils/file.py | 15 | ||||
| -rw-r--r-- | python/vyos/utils/process.py | 6 |
2 files changed, 21 insertions, 0 deletions
diff --git a/python/vyos/utils/file.py b/python/vyos/utils/file.py index 6708ade2d..f230977a7 100644 --- a/python/vyos/utils/file.py +++ b/python/vyos/utils/file.py @@ -339,3 +339,18 @@ def file_compare(file1: str, file2: str) -> bool: return False return True + + +def get_name_from_path(path) -> str: + """ + Extracts the base name (without extension) from a file path. + + Args: + path (str | pathlib.Path): The file path to extract the name from. + + Returns: + str: The base name without file extension. + """ + base = os.path.basename(path) + name, _ = base.split('.', maxsplit=1) + return name diff --git a/python/vyos/utils/process.py b/python/vyos/utils/process.py index 158371024..74546a172 100644 --- a/python/vyos/utils/process.py +++ b/python/vyos/utils/process.py @@ -321,3 +321,9 @@ def ip_cmd(args, json=True): else: res = cmd(f"ip {args}") return res + + +def wrap_op(cmd: str) -> str: + """Returns a command with the VyOS operational mode wrapper.""" + + return f'/opt/vyatta/bin/vyatta-op-cmd-wrapper {cmd}' |
