def _get_models_from_directory(from_directory): payload = [] for entry in scantree(from_directory): if not entry.name.endswith(".json"): logger.debug( "Skipping {} - model file must end with .json".format(entry.path) ) continue entry_json = process_json_arg(content=entry.path, argument_name=entry.name) payload.append(entry_json) return _get_models_metadata(payload)
def _process_directory(self, from_directory): logger.debug( "Documents contained in directory: {}, processing...".format( from_directory)) payload = [] for entry in scantree(from_directory): if all([ not entry.name.endswith(".json"), not entry.name.endswith(".dtdl") ]): logger.debug( "Skipping {} - model file must end with .json or .dtdl". format(entry.path)) continue entry_json = process_json_arg(content=entry.path, argument_name=entry.name) payload.append(entry_json) return payload
def _process_models_directory(from_directory): from azext_iot.common.utility import scantree, process_json_arg, read_file_content # we need to double-encode the JSON string from json import dumps models = [] if os.path.isfile(from_directory) and (from_directory.endswith(".json") or from_directory.endswith(".dtdl")): models.append(dumps(read_file_content(file_path=from_directory))) return models for entry in scantree(from_directory): if not any([entry.name.endswith(".json"), entry.name.endswith(".dtdl")]): logger.debug( "Skipping {} - model file must end with .json or .dtdl".format( entry.path ) ) continue entry_json = process_json_arg(content=entry.path, argument_name=entry.name) models.append(dumps(entry_json)) return models