-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolkit.py
42 lines (32 loc) · 1.82 KB
/
toolkit.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
import argparse
from datetime import datetime, timedelta
class UnreconizedParmException(Exception):
def __init__(self, message: object) -> None:
super().__init__(message)
self.value = message
def main_arguments() -> object:
parser = argparse.ArgumentParser(description="G2A uploader program",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--website', '-w', dest='website', default='', help="Nom du plateforme des donnees de scrap")
parser.add_argument('--frequency', '-f', dest='frequency',
default='', help="frequence de nuitee de scrap")
parser.add_argument('--name', '-n', dest='name',
default='', help="Le nom du fichier source sans extension")
parser.add_argument('--target', '-t', dest='target',
default='dev', help="API dev ou prod")
parser.add_argument('--date-snapshot', '-d', dest='snapshotdate', help="Le samedi de la semaine de scrap")
return parser.parse_args()
ARGS_INFO = {
'-w': {'long': '--website', 'dest': 'website', "help": "Nom du plateforme source des donnees"},
'-f': {'long': '--frequency', 'dest': 'frequency', "help": "frequence de nuitee"},
'-n': {'long': '--name', 'dest': 'name', "help": "Nom du fichier source"},
'-t': {'long': '--target', 'dest': 'target', "help": "API a utiliser, dev ou prod"},
'-d': {'long': '--date-snapshot', 'dest': 'snapshotdate', "help": "saturday of week scrap"}
}
def check_arguments(args, required):
miss = []
for item in required:
if not getattr(args, ARGS_INFO[item]['dest']):
miss.append(
f'{item} ou {ARGS_INFO[item]["long"]} ({ARGS_INFO[item]["help"]})')
return miss