-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.py
53 lines (34 loc) · 1.37 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import random
import string
from gornilo import Verdict
SEED = string.ascii_letters + string.digits
def get_rnd_string(length: int = 32):
return ''.join(random.choice(SEED) for _ in range(length))
def get_rnd_int(min_val=0, max_val: int = 2):
return random.randint(min_val, max_val)
def raise_data_exc(obj, actual):
raise VerdictDataException(Verdict.CORRUPT(
f"Received incorrect {obj}."),
f"Actual was: {actual}.")
def raise_not_found_exc(obj, actual):
raise VerdictNotFoundException(Verdict.CORRUPT(
f"Could not find recently added {obj}."),
f"Actual was: {actual}.")
class VerdictHttpException(Exception):
def __init__(self, verdict=None, message: str = None):
self.verdict = verdict
self.message = message
def __str__(self):
return f"{str(self.verdict._public_message)}||{self.message}"
class VerdictDataException(Exception):
def __init__(self, verdict=None, message: str = None):
self.verdict = verdict
self.message = message
def __str__(self):
return f"{str(self.verdict._public_message)}||{self.message}"
class VerdictNotFoundException(Exception):
def __init__(self, verdict=None, message: str = None):
self.verdict = verdict
self.message = message
def __str__(self):
return f"{str(self.verdict._public_message)}||{self.message}"