Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_id_value(value):
if not value or value == '_':
return None
if fullmatch(ID_SINGLE, value):
return int(value)
elif fullmatch(ID_RANGE, value):
from_, to = value.split("-")
from_, to = int(from_), int(to)
if to > from_:
return (int(from_), "-", int(to))
elif fullmatch(ID_DOT_ID, value):
return (int(value.split(".")[0]), ".", int(value.split(".")[1]))
raise ParseException("'{}' is not a valid ID.".format(value))
def parse_paired_list_value(value):
if fullmatch(MULTI_DEPS_PATTERN, value):
return [
(part.split(":", 1)[1], parse_id_value(part.split(":")[0]))
for part in value.split("|")
]
return parse_nullable_value(value)
def parse_id_value(value):
if not value or value == '_':
return None
if fullmatch(ID_SINGLE, value):
return int(value)
elif fullmatch(ID_RANGE, value):
from_, to = value.split("-")
from_, to = int(from_), int(to)
if to > from_:
return (int(from_), "-", int(to))
elif fullmatch(ID_DOT_ID, value):
return (int(value.split(".")[0]), ".", int(value.split(".")[1]))
raise ParseException("'{}' is not a valid ID.".format(value))
def parse_id_value(value):
if not value or value == '_':
return None
if fullmatch(ID_SINGLE, value):
return int(value)
elif fullmatch(ID_RANGE, value):
from_, to = value.split("-")
from_, to = int(from_), int(to)
if to > from_:
return (int(from_), "-", int(to))
elif fullmatch(ID_DOT_ID, value):
return (int(value.split(".")[0]), ".", int(value.split(".")[1]))
raise ParseException("'{}' is not a valid ID.".format(value))
def parse_int_value(value):
if value == '_':
return None
if fullmatch(INTEGER, value):
return int(value)
else:
raise ParseException("'{}' is not a valid value for parse_int_value.".format(value))