Skip to content

Commit 65dd22e

Browse files
committed
Extract config path into a constant
1 parent f99ef5b commit 65dd22e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cfg/auth.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
import json
99
import sys
1010

11+
CONFIG_PATH = '../cfg/config.cfg'
1112

1213
# Configuration of the firebase database
1314
def firebase_admin_auth():
1415
try:
15-
with open('../cfg/config.cfg') as json_data_file:
16+
with open(CONFIG_PATH) as json_data_file:
1617
data = json.load(json_data_file)
1718
api_key = data['firebase']['api_key']
1819
auth_domain = data['firebase']['auth_domain']
@@ -40,7 +41,7 @@ def firebase_admin_auth():
4041

4142
def dev_firebase_admin_auth():
4243
try:
43-
with open('../cfg/config.cfg') as json_data_file:
44+
with open(CONFIG_PATH) as json_data_file:
4445
data = json.load(json_data_file)
4546
api_key = data['dev_firebase']['api_key']
4647
auth_domain = data['dev_firebase']['auth_domain']
@@ -71,7 +72,7 @@ def dev_firebase_admin_auth():
7172
# get the api_key
7273
def get_api_key(tileserver):
7374
try:
74-
with open('../cfg/config.cfg') as json_data_file:
75+
with open(CONFIG_PATH) as json_data_file:
7576
data = json.load(json_data_file)
7677
api_key = data['imagery'][tileserver]
7778
return api_key
@@ -84,7 +85,7 @@ def get_api_key(tileserver):
8485
# get the import submission_key
8586
def get_submission_key():
8687
try:
87-
with open('../cfg/config.cfg') as json_data_file:
88+
with open(CONFIG_PATH) as json_data_file:
8889
data = json.load(json_data_file)
8990
submission_key = data['import']['submission_key']
9091
return submission_key
@@ -100,7 +101,7 @@ class mysqlDB(object):
100101
def __init__(self):
101102
# try to load configuration from config file
102103
try:
103-
with open('../cfg/config.cfg') as json_data_file:
104+
with open(CONFIG_PATH) as json_data_file:
104105
data = json.load(json_data_file)
105106
dbname = data['mysql']['database']
106107
user = data['mysql']['username']
@@ -146,7 +147,7 @@ class dev_mysqlDB(object):
146147
def __init__(self):
147148
# try to load configuration from config file
148149
try:
149-
with open('../cfg/config.cfg') as json_data_file:
150+
with open(CONFIG_PATH) as json_data_file:
150151
data = json.load(json_data_file)
151152
dbname = data['dev_mysql']['database']
152153
user = data['dev_mysql']['username']

0 commit comments

Comments
 (0)