forked from sendgrid/open-source-library-data-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
61 lines (50 loc) · 1.85 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import yaml
class Config(object):
"""All configuration for this app is loaded here"""
def __init__(self):
if (os.environ.get('ENV') != 'prod'): # We are not in Heroku
self.init_environment()
"""Allow variables assigned in config.yml available the following variables
via properties"""
self.base_path = os.path.abspath(os.path.dirname(__file__))
with open(self.base_path + '/config.yml') as stream:
config = yaml.load(stream)
self._github_user = config['github_user'][0]
self._github_repos = config['github_repos']
self._package_manager_urls = config['package_manager_urls']
self._to_email = config['email']['to']
self._from_email = config['email']['from']
self._email_subject = config['email']['subject']
self._email_body = config['email']['body']
@staticmethod
def init_environment():
"""Allow variables assigned in .env available using
os.environ.get('VAR_NAME')"""
base_path = os.path.abspath(os.path.dirname(__file__))
if os.path.exists(base_path + '/.env'):
for line in open(base_path + '/.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
@property
def github_user(self):
return self._github_user
@property
def github_repos(self):
return self._github_repos
@property
def package_manager_urls(self):
return self._package_manager_urls
@property
def to_email(self):
return self._to_email
@property
def from_email(self):
return self._from_email
@property
def email_subject(self):
return self._email_subject
@property
def email_body(self):
return self._email_body