mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-19 03:10:22 -07:00
osx_defaults: fix handling negative integers (#676)
* osx_defaults: fix handling negative integers * add changelog fragment
This commit is contained in:
parent
d7aabcceed
commit
c207b7298c
3 changed files with 12 additions and 1 deletions
|
@ -169,6 +169,14 @@ class OSXDefaults(object):
|
|||
# /init --------------------------------------------------------------- }}}
|
||||
|
||||
# tools --------------------------------------------------------------- {{{
|
||||
@staticmethod
|
||||
def is_int(value):
|
||||
as_str = str(value)
|
||||
if (as_str.startswith("-")):
|
||||
return as_str[1:].isdigit()
|
||||
else:
|
||||
return as_str.isdigit()
|
||||
|
||||
@staticmethod
|
||||
def _convert_type(data_type, value):
|
||||
""" Converts value to given type """
|
||||
|
@ -190,7 +198,7 @@ class OSXDefaults(object):
|
|||
"Invalid date value: {0}. Required format yyy-mm-dd hh:mm:ss.".format(repr(value))
|
||||
)
|
||||
elif data_type in ["int", "integer"]:
|
||||
if not str(value).isdigit():
|
||||
if not OSXDefaults.is_int(value):
|
||||
raise OSXDefaultsException("Invalid integer value: {0}".format(repr(value)))
|
||||
return int(value)
|
||||
elif data_type == "float":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue