labpack/records/settings.py
def ingest_environ(model_path=''):

    ''' a method to convert environment variables to a python dictionary

    :param model_path: [optional] string with path to jsonmodel of data to ingest
    :return: dictionary with environmental variables

    NOTE:   if a model is provided, then only those fields in the model will be
            added to the output and the value of any environment variable which
            matches the uppercase name of each field in the model will be added
            to the dictionary if its value is valid according to the model. if
            a value is not valid, the method will produce the default value of
            the model
    '''

# convert environment variables into json typed data
    from os import environ, path
    typed_dict = {}
    environ_variables = dict(environ)
    for key, value in environ_variables.items():
        if value.lower() == 'true':
            typed_dict[key] = True
        elif value.lower() == 'false':
            typed_dict[key] = False
        elif value.lower() == 'null':
            typed_dict[key] = None
        elif value.lower() == 'none':
            typed_dict[key] = None
        else:
            try:
                try:
                    typed_dict[key] = int(value)
                except:
                    typed_dict[key] = float(value)
            except:
                typed_dict[key] = value

# feed environment variables through model
    if model_path:
        if not path.exists(model_path):
            raise ValueError('%s is not a valid file path.' % model_path)
        model_dict = load_settings(model_path)
        from jsonmodel.validators import jsonModel
        model_object = jsonModel(model_dict)
        default_dict = model_object.ingest(**{})
        ingest_dict = {}
        for key in default_dict.keys():
            if key.upper() in typed_dict.keys():
                ingest_dict[key] = typed_dict[key.upper()]

        return model_object.ingest(**ingest_dict)

    return typed_dict
 a method to convert environment variables to a python dictionary

    :param model_path: [optional] string with path to jsonmodel of data to ingest
    :return: dictionary with environmental variables

    NOTE:   if a model is provided, then only those fields in the model will be
            added to the output and the value of any environment variable which
            matches the uppercase name of each field in the model will be added
            to the dictionary if its value is valid according to the model. if
            a value is not valid, the method will produce the default value of
            the model
    
a method to convert environment variables to a python dictionary
a method to convert environment variables to a python dictionary
def ingest_environ(model_path=''):
    from os import environ, path
    typed_dict = {}
    environ_variables = dict(environ)
    for key, value in environ_variables.items():
        if value.lower() == 'true':
            typed_dict[key] = True
        elif value.lower() == 'false':
            typed_dict[key] = False
        elif value.lower() == 'null':
            typed_dict[key] = None
        elif value.lower() == 'none':
            typed_dict[key] = None
        else:
            try:
                try:
                    typed_dict[key] = int(value)
                except:
                    typed_dict[key] = float(value)
            except:
                typed_dict[key] = value
    if model_path:
        if not path.exists(model_path):
            raise ValueError('%s is not a valid file path.' % model_path)
        model_dict = load_settings(model_path)
        from jsonmodel.validators import jsonModel
        model_object = jsonModel(model_dict)
        default_dict = model_object.ingest(**{})
        ingest_dict = {}
        for key in default_dict.keys():
            if key.upper() in typed_dict.keys():
                ingest_dict[key] = typed_dict[key.upper()]
        return model_object.ingest(**ingest_dict)
    return typed_dict
def ingest_environ ( model_path = '' ) : from os import environ , path typed_dict = { } environ_variables = dict ( environ ) for key , value in environ_variables . items ( ) : if value . lower ( ) == 'true' : typed_dict [ key ] = True elif value . lower ( ) == 'false' : typed_dict [ key ] = False elif value . lower ( ) == 'null' : typed_dict [ key ] = None elif value . lower ( ) == 'none' : typed_dict [ key ] = None else : try : try : typed_dict [ key ] = int ( value ) except : typed_dict [ key ] = float ( value ) except : typed_dict [ key ] = value if model_path : if not path . exists ( model_path ) : raise ValueError ( '%s is not a valid file path.' % model_path ) model_dict = load_settings ( model_path ) from jsonmodel . validators import jsonModel model_object = jsonModel ( model_dict ) default_dict = model_object . ingest ( ** { } ) ingest_dict = { } for key in default_dict . keys ( ) : if key . upper ( ) in typed_dict . keys ( ) : ingest_dict [ key ] = typed_dict [ key . upper ( ) ] return model_object . ingest ( ** ingest_dict ) return typed_dict
a method to convert environment variables to a python dictionary
a method to convert environment variables to a python dictionary
''' a method to convert environment variables to a python dictionary

    :param model_path: [optional] string with path to jsonmodel of data to ingest
    :return: dictionary with environmental variables

    NOTE:   if a model is provided, then only those fields in the model will be
            added to the output and the value of any environment variable which
            matches the uppercase name of each field in the model will be added
            to the dictionary if its value is valid according to the model. if
            a value is not valid, the method will produce the default value of
            the model
    ''' # convert environment variables into json typed data
 # feed environment variables through model

dictionary with environmental variables
NOTE:   if a model is provided, then only those fields in the model will be
added to the output and the value of any environment variable which
matches the uppercase name of each field in the model will be added
to the dictionary if its value is valid according to the model. if
a value is not valid, the method will produce the default value of
the model
dictionary with environmental variables NOTE : if a model is provided then only those fields in the model will be added to the output and the value of any environment variable which matches the uppercase name of each field in the model will be added to the dictionary if its value is valid according to the model . if a value is not valid the method will produce the default value of the model
model_path
[optional] string with path to jsonmodel of data to ingest
[ optional ] string with path to jsonmodel of data to ingest