main.configure_logging()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 16
nop 1
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
1
import logging
2
import sys
3
4
from dotenv import load_dotenv
5
6
from src.kalauz.OSM_data_processors.mapper import Mapper
7
8
9
# future: mark all packages as namespace packages in the IDE when https://youtrack.jetbrains.com/issue/PY-55212/ is fixed
10
11
12
def main(
13
    demonstration=True,
14
    show_lines_with_no_data=True,
15
) -> None:
16
    configure_logging(demonstration)
17
    logging.getLogger(__name__).info("Program started...")
18
19
    load_dotenv()
20
21
    # CountriesUpdater().run()
22
    # CompaniesUpdater().run()
23
    # OperatingSitesUpdater().run()
24
25
    # NewFilesRegistrar().run()
26
    
27
    # with CategoryPredictor() as category_predictor:
28
        # MavUpdater(category_predictor).run()
29
        # GysevUpdater(category_predictor).run()
30
31
    Mapper(show_lines_with_no_data).run()
32
33
    logging.getLogger(__name__).info("...program finished!")
34
35
36
def configure_logging(demonstration: bool) -> None:
37
    if demonstration:
38
        logging.basicConfig(
39
            encoding="utf-8",
40
            handlers=[
41
                logging.StreamHandler(sys.stdout),
42
                logging.FileHandler("kalauz.log"),
43
            ],
44
            format="%(asctime)s [%(levelname)s]: %(message)s",
45
            level=logging.INFO,
46
        )
47
    else:
48
        logging.basicConfig(
49
            encoding="utf-8",
50
            handlers=[
51
                logging.StreamHandler(),
52
                logging.FileHandler("kalauz.log"),
53
            ],
54
            format='%(asctime)s [%(levelname)s] "%(pathname)s:%(lineno)d": %(message)s',
55
            level=logging.DEBUG,
56
        )
57
58
59
if __name__ == "__main__":
60
    main()
61