32 lines
717 B
Python
32 lines
717 B
Python
# -*- coding: utf-8 -*-
|
|
import random
|
|
from typing import Tuple
|
|
from pprint import pprint
|
|
from datetime import datetime
|
|
|
|
pp = pprint
|
|
|
|
|
|
def re_generator(low: int = 5, high: int = 20) -> str:
|
|
return 'R{}'.format('E' * random.randint(low, high))
|
|
|
|
|
|
def date_from_iso(date: str) -> datetime:
|
|
return datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ')
|
|
|
|
|
|
def parse_int(val: str, select: bool = True) -> Tuple[int, str]:
|
|
try:
|
|
val = int(val)
|
|
if val is not 0:
|
|
if val < 1:
|
|
order = 'DESC'
|
|
val *= -1
|
|
else:
|
|
order = 'ASC'
|
|
if select:
|
|
val -= 1
|
|
return val, order
|
|
except ValueError:
|
|
pass
|