bug fix: configuration file reader

This commit is contained in:
Steve Nyemba 2021-01-18 10:24:45 -06:00
parent 9e085da5bf
commit b9ad861db9
2 changed files with 18 additions and 3 deletions

View File

@ -36,17 +36,20 @@ import requests
import time import time
PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','config.json']) PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','config.json'])
CONFIG = json.loads((open(PATH)).read())
STORE_URI = 'http://healthcareio.the-phi.com/store/healthcareio' STORE_URI = 'http://healthcareio.the-phi.com/store/healthcareio'
# #
# let us see if we have any custom configurations ... # let us see if we have any custom configurations ...
PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','custom']) PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','custom'])
CONFIG = {}
CUSTOM_CONFIG = {} CUSTOM_CONFIG = {}
if os.path.exists(PATH) and os.listdir(PATH) : if os.path.exists(PATH) and os.listdir(PATH) :
CONFIG = json.loads((open(PATH)).read())
PATH = os.sep.join([PATH,os.listdir(PATH)[0]]) PATH = os.sep.join([PATH,os.listdir(PATH)[0]])
CUSTOM_CONFIG = json.loads((open(PATH)).read()) CUSTOM_CONFIG = json.loads((open(PATH)).read())
_args = dict(CONFIG['store'],**{'type':'mongo.MongoReader'}) # _args = dict(CONFIG['store'],**{'type':'mongo.MongoReader'})
def get_field_names (_map,label): def get_field_names (_map,label):
fields = list(_map.keys()) fields = list(_map.keys())
@ -182,6 +185,18 @@ class Factory:
:param type EDI type to be processed i.e 835 or 837 :param type EDI type to be processed i.e 835 or 837
:param write_store target data-store (redshift, mariadb,mongodb ...) :param write_store target data-store (redshift, mariadb,mongodb ...)
""" """
global PATH
global CONFIG
global CUSTOM_CONFIG
PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','config.json'])
if os.path.exists(PATH):
CONFIG = json.loads((open(PATH)).read())
CUSTOM_PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','custom'])
if os.path.exists(CUSTOM_PATH) and os.listdir(CUSTOM_PATH) :
CUSTOM_PATH = os.sep.join([CUSTOM_PATH,os.listdir(CUSTOM_PATH)[0]])
CUSTOM_CONFIG = json.loads((open(CUSTOM_PATH)).read())
_features = Factory.license(email=CONFIG['owner']) _features = Factory.license(email=CONFIG['owner'])
store = copy.deepcopy(CONFIG['store']) store = copy.deepcopy(CONFIG['store'])
store['type']='mongo.MongoReader' store['type']='mongo.MongoReader'

View File

@ -8,7 +8,7 @@ import sys
def read(fname): def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read() return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = { args = {
"name":"healthcareio","version":"1.4.8", "name":"healthcareio","version":"1.5.0",
"author":"Vanderbilt University Medical Center", "author":"Vanderbilt University Medical Center",
"author_email":"steve.l.nyemba@vumc.org", "author_email":"steve.l.nyemba@vumc.org",
"include_package_data":True, "include_package_data":True,