-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescribe.py
53 lines (45 loc) · 1.49 KB
/
describe.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 sys
from app.exceptions import (
FunctionNotSpecified,
InvalidFunction
)
from app.enums import FunctionName
from app.exceptions import ScriptError
from app.config import (
ALLOW_PHOTO_BY_DEFAULT,
ADD_REGISTRATIONS,
ALLOW_PHOTO_BY_EVENT,
CREATE_BINGO,
DELETE_FILE,
UPLOAD_FILE
)
def describe_function():
"""
Describe the function.
"""
try:
if len(sys.argv) < 2:
raise FunctionNotSpecified("Du må oppgi en funksjon for å få en beskrivelse av den.")
function = sys.argv[1]
match function:
case FunctionName.ALLOW_PHOTO_BY_EVENT.value:
print(ALLOW_PHOTO_BY_EVENT)
case FunctionName.ALLOW_PHOTO_BY_DEFAULT.value:
print(ALLOW_PHOTO_BY_DEFAULT)
case FunctionName.CREATE_BINGO.value:
print(CREATE_BINGO)
case FunctionName.ADD_REGISTRATIONS.value:
print(ADD_REGISTRATIONS)
case FunctionName.UPLOAD_FILE.value:
print(UPLOAD_FILE)
case FunctionName.DELETE_FILE.value:
print(DELETE_FILE)
case _:
raise InvalidFunction()
except Exception as e:
if isinstance(e, ScriptError):
print(f"\n{e}\n")
return
print(f"\nEn ukjent feil oppstod, med følgende beskjed: \n\n{e}\n\nVennligst prøv igjen. Hvis problemet vedvarer, kontakt Index.")
if __name__ == "__main__":
describe_function()