18 lines
405 B
Python
18 lines
405 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
|
|
def parse_int(val: str, select: bool = True) -> tuple:
|
|
try:
|
|
val = int(val)
|
|
if val is not 0:
|
|
if val < 1:
|
|
order, op = 'desc', '<='
|
|
val *= -1
|
|
else:
|
|
order, op = 'asc', '>='
|
|
if select:
|
|
val -= 1
|
|
return val, order, op
|
|
except ValueError:
|
|
pass
|