2021-10-17 18:16:29 +02:00
|
|
|
import configparser
|
|
|
|
|
2021-10-17 22:21:07 +02:00
|
|
|
|
2021-10-17 18:16:29 +02:00
|
|
|
class Config:
|
2022-02-12 18:39:08 +01:00
|
|
|
def __init__(self, username, password, source_addr, db_insee_communes_sqlite_path, db_fantoir_voies_sqlite_path):
|
2021-10-17 18:16:29 +02:00
|
|
|
self.username = username
|
|
|
|
self.password = password
|
|
|
|
self.source_addr = source_addr
|
2022-02-12 18:39:08 +01:00
|
|
|
self.db_insee_communes_sqlite_path = db_insee_communes_sqlite_path
|
|
|
|
self.db_fantoir_voies_sqlite_path = db_fantoir_voies_sqlite_path
|
2021-10-17 18:16:29 +02:00
|
|
|
self.debug = False
|
|
|
|
|
2021-10-17 22:21:07 +02:00
|
|
|
|
2021-10-17 18:16:29 +02:00
|
|
|
def parse_config(cfgPath):
|
|
|
|
cfg = configparser.ConfigParser()
|
2021-10-17 22:21:07 +02:00
|
|
|
with open(cfgPath, "r") as f:
|
2021-10-17 18:16:29 +02:00
|
|
|
cfg.read_file(f)
|
2021-10-17 22:21:07 +02:00
|
|
|
username = cfg.get("API", "username")
|
|
|
|
passwd = cfg.get("API", "password")
|
|
|
|
source_addr = cfg.get("API", "source_addr")
|
2022-02-12 18:39:08 +01:00
|
|
|
db_insee_communes_sqlite_path = cfg.get("ADDRESSES","db_insee_communes_sqlite_path")
|
|
|
|
db_fantoir_voies_sqlite_path = cfg.get("ADDRESSES","db_fantoir_voies_sqlite_path")
|
|
|
|
return Config(username, passwd, source_addr,db_insee_communes_sqlite_path, db_fantoir_voies_sqlite_path)
|