Move configparser code to seperate module
This code is now in its own Class. This is to make it easier to do reporting and updating.
This commit is contained in:
parent
5856541a22
commit
811979cea7
@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import os
|
||||
from time import sleep
|
||||
import dir_activities
|
||||
import api_calls
|
||||
from prog_conf import gaa_conf
|
||||
|
||||
gaa_version = "2024.10.15.2"
|
||||
|
||||
@ -14,13 +14,15 @@ jls_extract_var = f'%(prog)s {gaa_version}'
|
||||
option_set.add_argument('--version', '-v', action='version', version=jls_extract_var)
|
||||
cmd_options = option_set.parse_args()
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
if (os.path.exists('config.ini')):
|
||||
conf_path = 'config.ini'
|
||||
else:
|
||||
conf_path = os.path.join(os.path.expanduser("~"), ".local/share/get_artist_art/config.ini")
|
||||
# config = configparser.ConfigParser()
|
||||
# if (os.path.exists('config.ini')):
|
||||
# conf_path = 'config.ini'
|
||||
# else:
|
||||
# conf_path = os.path.join(os.path.expanduser("~"), ".local/share/get_artist_art/config.ini")
|
||||
|
||||
config.read(conf_path)
|
||||
# config.read(conf_path)
|
||||
config = gaa_conf()
|
||||
config = config.conf
|
||||
|
||||
music_path = config['music']['dir']
|
||||
ftv_api_key = config['fanart_tv']['api_key']
|
||||
|
16
prog_conf.py
Normal file
16
prog_conf.py
Normal file
@ -0,0 +1,16 @@
|
||||
import configparser
|
||||
from os.path import exists,join,expanduser
|
||||
|
||||
|
||||
class gaa_conf:
|
||||
def __init__(self):
|
||||
self.conf = configparser.ConfigParser()
|
||||
if (exists('config.ini')):
|
||||
self.conf_path = 'config.ini'
|
||||
else:
|
||||
self.conf_path = join(expanduser(
|
||||
"~"), ".local/share/get_artist_art/config.ini")
|
||||
self.conf.read(self.conf_path)
|
||||
|
||||
def get():
|
||||
return gaa_conf
|
Loading…
x
Reference in New Issue
Block a user