]> AND Private Git Repository - predictops.git/blob - main.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
cleaning main.py file
[predictops.git] / main.py
1 from lib.source import MeteoFrance
2
3 from logging import getLogger
4 from logging.config import fileConfig
5 from pathlib import Path
6 from shutil import rmtree
7
8
9 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
10 logger = getLogger()
11
12
13 class Engine:
14     def __init__(self, clean = False):
15         logger.info("Predictops engine launched")
16         if clean:
17             self.clean()
18             print("To prevent from downloading again csv files, copy the archive in data rep")
19
20     def clean(self):
21         # Cleaning the data directory
22         logger.info("Cleaning and restoring data directory")
23         directory  = Path.cwd() / 'data'
24         if directory.is_dir():
25             rmtree(directory)
26         p = Path(Path.cwd() / 'data')
27         p.mkdir()
28
29
30     def add_meteofrance(self):
31         self.meteofrance = MeteoFrance()
32
33
34
35 engine = Engine(clean = False)
36 engine.add_meteofrance()
37 engine.meteofrance.update()
38 print(len(engine.meteofrance.dated_features))