axione-elig-test/axione_api/config.py

20 lines
530 B
Python
Raw Normal View History

2021-10-17 18:16:29 +02:00
import configparser
2021-10-17 18:16:29 +02:00
class Config:
def __init__(self, username, password, source_addr):
self.username = username
self.password = password
self.source_addr = source_addr
self.debug = False
2021-10-17 18:16:29 +02:00
def parse_config(cfgPath):
cfg = configparser.ConfigParser()
with open(cfgPath, "r") as f:
2021-10-17 18:16:29 +02:00
cfg.read_file(f)
username = cfg.get("API", "username")
passwd = cfg.get("API", "password")
source_addr = cfg.get("API", "source_addr")
2021-10-17 18:16:29 +02:00
return Config(username, passwd, source_addr)