def load_data_definitions(datadir): """ Parse the yaml file of base yaml objects and return the information :arg file yaml_file: Open file object to read the yaml from :returns: An array of Markets that the user can travel to. """ _define_schemas(datadir) data_file = os.path.join(datadir, 'base', 'stellar-base.yml') with open(data_file) as f: loader = Loader(f.read()) base_data = loader.get_single_data() v_validate(base_data, BASE_SCHEMA) data_file = os.path.join(datadir, 'base', 'stellar-sol.yml') with open(data_file) as f: loader = Loader(f.read()) system_data = loader.get_single_data() v_validate(system_data, SYSTEM_SCHEMA) base_data.update(system_data) del base_data['version'] return base_data
def load_base_types(datadir): """ Parse the yaml file of base enum types and return the information :arg datadir: The data directory to find the types file :returns: A list of types """ flog = mlog.fields(func='load_base_types') flog.fields(datadir=datadir).debug('Entered load_base_types') data_file = os.path.join(datadir, 'base', 'stellar-types.yml') with_file_log = flog.fields(filename=data_file) with_file_log.debug('constructed data_file path {data_file}', data_file=data_file) with_file_log.debug('Opening data_file') with open(data_file, 'r') as data_fh: with_file_log.debug('reading data_file') yaml_data = data_fh.read() with_file_log.fields(yaml=yaml_data).debug('parsing yaml string') loader = Loader(yaml_data) data = loader.get_single_data() flog.fields(data=data).debug('Validating type data structure') data = v_validate(data, DATA_TYPES_SCHEMA) flog.debug('Returning type data') return data