-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
30 lines (24 loc) · 920 Bytes
/
config.py
File metadata and controls
30 lines (24 loc) · 920 Bytes
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
# This script load and parse the configuration parameters of the database
from configparser import ConfigParser
def get_config_db(file='database.ini', section='rokket-db'):
parser = ConfigParser()
parser.read(file)
db = {}
if parser.has_section(section):
params = parser.items(section)
for param in params:
db[param[0]] = param[1]
else:
raise Exception('Section {0} was not found in the file {1}'.format(section, file))
return db
def get_spotify_credentials(file='database.ini', section='spotify-credentials'):
parser = ConfigParser()
parser.read(file)
credentials = {}
if parser.has_section(section):
params = parser.items(section)
for param in params:
credentials[param[0]] = param[1]
else:
raise Exception('Section {0} was not found in the file {1}'.format(section, file))
return credentials