mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #48844 from AVeenstra/fix-python3-incompatibility
Fixed Python 3 incompatibility in methods in nilrt_ip and debian_ip.
This commit is contained in:
commit
83a5b3cc47
2 changed files with 18 additions and 28 deletions
|
@ -391,20 +391,14 @@ def __within(within=None, errmsg=None, dtype=None):
|
|||
|
||||
def __space_delimited_list(value):
|
||||
'''validate that a value contains one or more space-delimited values'''
|
||||
valid, _value, errmsg = False, value, 'space-delimited string'
|
||||
try:
|
||||
if hasattr(value, '__iter__'):
|
||||
valid = True # TODO:
|
||||
else:
|
||||
_value = value.split()
|
||||
if _value == []:
|
||||
raise ValueError
|
||||
valid = True
|
||||
except AttributeError:
|
||||
pass
|
||||
except ValueError:
|
||||
pass
|
||||
return (valid, _value, errmsg)
|
||||
if isinstance(value, str):
|
||||
value = value.strip().split()
|
||||
|
||||
if hasattr(value, '__iter__') and value != []:
|
||||
return (True, value, 'space-delimited string')
|
||||
else:
|
||||
return (False, value, '{0} is not a valid space-delimited value.\n'.format(value))
|
||||
|
||||
|
||||
SALT_ATTR_TO_DEBIAN_ATTR_MAP = {
|
||||
'dns': 'dns-nameservers',
|
||||
|
|
|
@ -99,20 +99,16 @@ def _space_delimited_list(value):
|
|||
'''
|
||||
validate that a value contains one or more space-delimited values
|
||||
'''
|
||||
valid, _value, errmsg = False, value, 'space-delimited string'
|
||||
try:
|
||||
if hasattr(value, '__iter__'):
|
||||
valid = True
|
||||
else:
|
||||
_value = value.split()
|
||||
if _value == []:
|
||||
raise ValueError
|
||||
valid = True
|
||||
except AttributeError:
|
||||
errmsg = '{0} is not a valid list.\n'.format(value)
|
||||
except ValueError:
|
||||
errmsg = '{0} is not a valid list.\n'.format(value)
|
||||
return (valid, errmsg)
|
||||
if isinstance(value, str):
|
||||
items = value.split(' ')
|
||||
valid = items and all(items)
|
||||
else:
|
||||
valid = hasattr(value, '__iter__') and (value != [])
|
||||
|
||||
if valid:
|
||||
return (True, 'space-delimited string')
|
||||
else:
|
||||
return (False, '{0} is not a valid list.\n'.format(value))
|
||||
|
||||
|
||||
def _validate_ipv4(value):
|
||||
|
|
Loading…
Add table
Reference in a new issue