diff options
author | Daniil Baturin <daniil@baturin.org> | 2019-10-24 11:32:05 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2019-10-24 11:32:05 +0200 |
commit | 8bf1b924055cac270d931666ad2b7fdb82fdebac (patch) | |
tree | 01a7bae71ace12b69f1557f4d6cfe354e66e36e1 /python/vyos | |
parent | 8ccf3900d4962a855cd3cbafda90566fad4794b8 (diff) | |
download | vyos-1x-8bf1b924055cac270d931666ad2b7fdb82fdebac.tar.gz vyos-1x-8bf1b924055cac270d931666ad2b7fdb82fdebac.zip |
[vyos.config] T1764: support both string and list arguments in config functions.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/config.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/python/vyos/config.py b/python/vyos/config.py index 2232d900c..3a340b2da 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -126,7 +126,12 @@ class Config(object): # splitting at whitespace is reasonably safe. # It may cause problems with exists() when it's used for checking values, # since values may contain whitespace. - path = re.split(r'\s*', path) + if isinstance(path, str): + path = re.split(r'\s*', path) + elif isinstance(path, list): + pass + else: + raise TypeError("Path must be a whitespace-separated string or a list") return (self._level + path) def _run(self, cmd): @@ -155,7 +160,12 @@ class Config(object): # Make sure there's always a space between default path (level) # and path supplied as method argument # XXX: for small strings in-place concatenation is not a problem - self._level = re.split(r'\s*', path) + if isinstance(path, str): + self._level = re.split(r'\s*', path) + elif isinstance(path, list): + self._level = path + else: + raise TypeError("Level path must be either a whitespace-separated string or a list") def get_level(self): """ |