-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_local_config_generator.py
More file actions
58 lines (47 loc) · 1.32 KB
/
_local_config_generator.py
File metadata and controls
58 lines (47 loc) · 1.32 KB
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
import os
def get_var(key: str, default=None) -> str:
"""
Function for getting variable value from environment.
:param key: str
variable name.
:param default
default value
:return: str
variable value.
"""
result = os.environ.get(key)
if result is None:
if default:
return default
raise Exception(f'In your environment no {key} find.')
else:
return result
def print_template():
"""
function for printing template to the local_config.py file
:return: None
"""
with open("./backend/local_config.py", 'w') as f:
f.write(f"""
import os
class Development(object):
\"\"\"
Development environment configuration
\"\"\"
DEBUG = {get_var("DEBUG_DEV",'True')}
TESTING = {get_var("TESTING_DEV", 'False')}
MONGO_URI = "{get_var("MONGO_URI_DEV")}"
SENTRY_DSN = "{get_var("SENTRY_DSN")}"
SECRET_KEY = "{get_var("SECRET_KEY")}"
class Production(object):
\"\"\"
Production environment configurations
\"\"\"
DEBUG = {get_var("DEBUG_PROD", 'False')}
TESTING = {get_var("TESTING_PROD", 'False')}
MONGO_URI = "{get_var("MONGO_URI_PROD")}"
SENTRY_DSN = "{get_var("SENTRY_DSN")}"
SECRET_KEY = "{get_var("SECRET_KEY")}"
""")
if __name__ == "__main__":
print_template()