You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
553 B
Python

4 years ago
def parse_limits(limits):
if not limits:
return [None, None]
limits = limits.strip()
if limits[0] == '-':
return [None, int(limits[1:])]
elif limits[-1] == '-':
return [int(limits[:-1]), None]
limits = limits.split("-")
if len(limits) != 2:
print("unknown limits: " + str(limits) + " - using no limits")
return [None, None]
try:
return [int(x) for x in limits]
except ValueError as exp:
print(exp + " - using no limits")
return [None, None]