-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (26 loc) · 1.15 KB
/
main.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
import argparse
import logging as logger
from processors.generator import Generator
from processors.scanner import Scanner
from processors.utils import Config
logger.basicConfig(level='INFO',
format='%(levelname).1s %(asctime)s %(filename)s:%(lineno)s [%(funcName)s] %(message)s')
PROCESSORS = ['scanner', 'generator']
def execute_processor(config, args):
if args.processor == 'scanner':
scanner = Scanner(config)
scanner.scan()
elif args.processor == 'generator':
generator = Generator(config, args.year)
generator.generate()
def main():
config = Config()
years = list(config.get('generator'))
default_year = max(years)
parser = argparse.ArgumentParser(description='Run a processor for the given year')
parser.add_argument('-p', '--processor', choices=PROCESSORS, default='scanner', help='processor to be run, default: scanner')
parser.add_argument('-y', '--year', choices=years, default=default_year, help='year used by the processor, default: most recent configured year')
args = parser.parse_args()
execute_processor(config, args)
if __name__=='__main__':
main()