- Options use a more robust int callback by default (handles hex and oct digits as well)

- over.misc.hexdump extended with initial_offset
This commit is contained in:
Martinez 2017-10-09 23:51:38 +02:00
parent e699be5c6d
commit e9556c1fbe
4 changed files with 29 additions and 4 deletions

View file

@ -78,3 +78,24 @@ def directory(exists=False, writable=False, gio=False):
return path
return cb
def integer(arg):
"""
Converts
- "0x2a" 42
- "0o52" 42
- "42" 42
@while converting argument to int
"""
if type(arg) == int:
return arg
if len(arg) > 2:
if arg[1] == "x":
return int(arg, 16)
elif arg[1] == "o":
return int(arg, 8)
return int(arg)