separación de codigo para facil edición
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
32
app/config_parser.py
Normal file
32
app/config_parser.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import json, os
|
||||
from app import arg_parser
|
||||
|
||||
args = arg_parser.ArgParser().parse()
|
||||
|
||||
|
||||
class ConfigParser:
|
||||
config = None
|
||||
|
||||
def __init__(self):
|
||||
self.loadConfig()
|
||||
|
||||
def loadConfig(self):
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
path = os.path.join(ROOT_DIR, '../config.json')
|
||||
|
||||
if args.config:
|
||||
path = args.config
|
||||
|
||||
with open(path, 'r') as f:
|
||||
self.config = json.load(f)
|
||||
|
||||
if args.geoLatitude:
|
||||
self.config['geo']['latitude'] = args.geoLatitude
|
||||
if args.geoLongitude:
|
||||
self.config['geo']['longitude'] = args.geoLongitude
|
||||
if args.user:
|
||||
self.config['user'] = args.user
|
||||
if args.geoAccuracy:
|
||||
self.config['geo']['accuracy'] = args.geoAccuracy
|
||||
|
||||
return self.config
|
||||
Reference in New Issue
Block a user