def _main(): """Main entry point. """ doc = pyesdoc.read(options.file, options.encoding) print pyesdoc.encode(doc, pyesdoc.ENCODING_JSON)
def init(institution_id): """Initialises seedings from institutional seeding config files. :param str institution_id: ID of institution being processed. """ # Reset. global DOCUMENTS DOCUMENTS = list() # Set root folder path. fpath = os.getenv('CMIP6_HOME') fpath = os.path.join(fpath, 'repos') fpath = os.path.join(fpath, 'institutional') fpath = os.path.join(fpath, institution_id) fpath = os.path.join(fpath, 'cmip5') fpath = os.path.join(fpath, 'models') if not os.path.exists(fpath): return # Cache each model's cim document. for model_id in os.listdir(fpath): path = os.path.join(fpath, model_id) path = os.path.join(path, 'cim') if not os.path.exists(path): continue # Cache extended documents. for fname in os.listdir(path): doc_path = os.path.join(path, fname) DOCUMENTS.append(pyesdoc.extend(pyesdoc.read(doc_path))) return len(DOCUMENTS) > 0
def get_document(self, extend=True): """Returns deserialized document. :returns: Deserialized archived document. :rtype: object """ # Read from file system. try: document = pyesdoc.read(self.path) except Exception as err: raise exceptions.LoadingException(err) # Parse - performs project/source specific processing. try: pyesdoc.archive.parse(document, self.encoding, self.project, self.source) except Exception as err: raise exceptions.ParsingException(err) # Extend - performs generic processing. if extend: try: pyesdoc.extend(document) except exceptions.ExtendingException as err: raise err except Exception as err: raise exceptions.ExtendingException(err) return document
def _main(): """Main entry point. """ doc = pyesdoc.read(options.file, options.encoding) print pyesdoc.encode(doc, 'json')
def init(institution_id): """Initialises seedings from institutional seeding config files. :param str institution_id: ID of institution being processed. """ # Reset. global DOCUMENTS DOCUMENTS = list() # Set root folder path. fpath = os.getenv('ESDOC_HOME') fpath = os.path.join(fpath, 'repos') fpath = os.path.join(fpath, 'institutional') fpath = os.path.join(fpath, institution_id) fpath = os.path.join(fpath, 'cmip5') fpath = os.path.join(fpath, 'models') if not os.path.exists(fpath): return # Cache each model's cim document. for model_id in os.listdir(fpath): path = os.path.join(fpath, model_id) path = os.path.join(path, 'cim') if not os.path.exists(path): continue # Cache extended documents. for fname in os.listdir(path): doc_path = os.path.join(path, fname) DOCUMENTS.append(pyesdoc.extend(pyesdoc.read(doc_path))) return len(DOCUMENTS) > 0
def _main(): """Main entry point. """ # Open document & validate. doc = pyesdoc.read(options.file) report = pyesdoc.validate(doc) # Inform user of validation result. if report: if options.outfile: _emit_to_file_system(report) else: _emit_to_stdout(report) else: pyesdoc.rt.log("Documemt is valid.")
def _yield_documents(input_dir, doc_type): """Yields set of document for further processing. """ for fpath in glob.iglob("{}/{}*.*".format(input_dir, doc_type)): yield pyesdoc.read(fpath)
def _yield_documents(input_dir, type_key): """Yields set of document for further processing. """ for fpath in glob.iglob("{}/{}*.*".format(input_dir, type_key)): yield pyesdoc.read(fpath)
def _main(): """Main entry point.""" for fp in _FILEPATHS: print pyesdoc.read(fp, pyesdoc.METAFOR_CIM_XML_ENCODING)