Skip to content

Commit 39f6f50

Browse files
author
matthias_schaub
committed
Black
1 parent aacb2fe commit 39f6f50

File tree

1 file changed

+30
-48
lines changed
  • mapswipe_workers/mapswipe_workers

1 file changed

+30
-48
lines changed

mapswipe_workers/mapswipe_workers/auth.py

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,31 @@ def load_config():
3030
def get_api_key(tileserver):
3131
CONFIG = load_config()
3232
try:
33-
if tileserver == 'custom':
33+
if tileserver == "custom":
3434
return None
3535
else:
36-
return CONFIG['imagery'][tileserver]['api_key']
36+
return CONFIG["imagery"][tileserver]["api_key"]
3737
except KeyError:
3838
print(
39-
f'Could not find the API key for imagery tileserver '
40-
f'{tileserver} in {CONFIG_PATH}.'
41-
)
39+
f"Could not find the API key for imagery tileserver "
40+
f"{tileserver} in {CONFIG_PATH}."
41+
)
4242
raise
4343

4444

4545
def get_tileserver_url(tileserver):
4646
CONFIG = load_config()
4747
try:
48-
if tileserver == 'custom':
48+
if tileserver == "custom":
4949
return None
5050
else:
51-
return CONFIG['imagery'][tileserver]['url']
51+
return CONFIG["imagery"][tileserver]["url"]
5252
except KeyError:
53-
print('Could not find the url for imagery tileserver {} in {}.'.format(
54-
tileserver,
55-
CONFIG_PATH
56-
))
53+
print(
54+
"Could not find the url for imagery tileserver {} in {}.".format(
55+
tileserver, CONFIG_PATH
56+
)
57+
)
5758
raise
5859

5960

@@ -76,13 +77,11 @@ def firebaseDB():
7677
except ValueError:
7778
cred = credentials.Certificate(SERVICE_ACCOUNT_KEY_PATH)
7879
config = load_config()
79-
databaseName = config['firebase']['database_name']
80-
databaseURL = f'https://{databaseName}.firebaseio.com'
80+
databaseName = config["firebase"]["database_name"]
81+
databaseURL = f"https://{databaseName}.firebaseio.com"
8182

8283
# Initialize the app with a service account, granting admin privileges
83-
firebase_admin.initialize_app(cred, {
84-
'databaseURL': databaseURL
85-
})
84+
firebase_admin.initialize_app(cred, {"databaseURL": databaseURL})
8685

8786
# Return the imported Firebase Realtime Database module
8887
return db
@@ -95,56 +94,39 @@ class postgresDB(object):
9594
def __init__(self):
9695
CONFIG = load_config()
9796
try:
98-
host = CONFIG['postgres']['host']
99-
port = CONFIG['postgres']['port']
100-
dbname = CONFIG['postgres']['database']
101-
user = CONFIG['postgres']['username']
102-
password = CONFIG['postgres']['password']
97+
host = CONFIG["postgres"]["host"]
98+
port = CONFIG["postgres"]["port"]
99+
dbname = CONFIG["postgres"]["database"]
100+
user = CONFIG["postgres"]["username"]
101+
password = CONFIG["postgres"]["password"]
103102
except KeyError:
104103
raise Exception(
105-
f'Could not load postgres credentials '
106-
f'from the configuration file'
107-
)
104+
f"Could not load postgres credentials " f"from the configuration file"
105+
)
108106

109107
self._db_connection = psycopg2.connect(
110-
database=dbname,
111-
user=user,
112-
password=password,
113-
host=host,
114-
port=port
115-
)
108+
database=dbname, user=user, password=password, host=host, port=port
109+
)
116110

117111
def query(self, query, data=None):
118112
self._db_cur = self._db_connection.cursor()
119113
self._db_cur.execute(query, data)
120114
self._db_connection.commit()
121115
self._db_cur.close()
122116

123-
def copy_from(
124-
self,
125-
f,
126-
table,
127-
columns
128-
):
117+
def copy_from(self, f, table, columns):
129118
self._db_cur = self._db_connection.cursor()
130-
self._db_cur.copy_from(
131-
f,
132-
table,
133-
columns=columns
134-
)
119+
self._db_cur.copy_from(f, table, columns=columns)
135120
self._db_connection.commit()
136121
self._db_cur.close()
137122

138123
def copy_expert(
139-
self,
140-
sql,
141-
file,
142-
):
124+
self, sql, file,
125+
):
143126
self._db_cur = self._db_connection.cursor()
144127
self._db_cur.copy_expert(
145-
sql,
146-
file,
147-
)
128+
sql, file,
129+
)
148130
self._db_connection.commit()
149131
self._db_cur.close()
150132

0 commit comments

Comments
 (0)