forked from SonyMobile/aosp-digest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
47 lines (41 loc) · 1.35 KB
/
config.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
35
36
37
38
39
40
41
42
43
44
45
46
47
#
# Copyright 2019 Sony Mobile Communications Inc.
# SPDX-License-Identifier: MIT
#
"""
Configuration classes and methods.
Contains only Config class, for the time being.
"""
import yaml
class SmtpConfig:
"""
Configuration class for email:
- url = url of the smtp server
- authentication = True if smtp server requires authentication
- uname = user name used for authentication on smtp_url
- from_address = 'From:' email address
"""
def __init__(self, url, authentication, uname, from_address):
self.url = url
self.authentication = authentication
self.uname = uname
self.from_address = from_address
class Config:
"""
Configuration class for runtime parameters:
- cache = filename of the cache file
- gerrit = url to the gerrit insance to inspect
- smtp = SmtpConfig instance
"""
def __init__(self):
with open("config.yaml") as fconfig:
config = yaml.safe_load(fconfig)
self.cache_filename = config["gerrit"]["cache_filename"]
self.gerrit_url = config["gerrit"]["url"]
self.project = config["gerrit"]["project"]
self.smtp = SmtpConfig(
config["smtp"]["url"],
config["smtp"]["authentication"],
config["smtp"]["uname"],
config["smtp"]["from"],
)