Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, value, units=None, gtlt=None):
if not units:
self._units = "M"
else:
if units.upper() not in distance.legal_units:
raise UnitsError("unrecognized distance unit: '" + units + "'")
self._units = units.upper()
try:
if value.startswith("M"):
value = value[1:]
gtlt = "<"
elif value.startswith("P"):
value = value[1:]
gtlt = ">"
except:
pass
if gtlt and gtlt not in distance.legal_gtlt:
raise ValueError(
"unrecognized greater-than/less-than symbol: '" + gtlt + "'"
)