def _create_collection(source, scope, collection_id, cfg): """Creates collection from a WCRP JSON file. """ # Create collection. collection = pyessv.create_collection( scope, collection_id, "WCRP CMIP6 CV collection: ".format(collection_id), label=cfg['label'] or collection_id.title().replace('_Id', '_ID').replace('_', ' '), create_date=_CREATE_DATE, term_regex=cfg['term_regex'] or pyessv.REGEX_CANONICAL_NAME, data = None if cfg['cim_document_type'] is None else { 'cim_document_type': cfg['cim_document_type'], 'cim_document_type_alternative_name': cfg['cim_document_type_alternative_name'] } ) # Load JSON data & create terms (if collection is not a virtual one). if cfg['is_virtual'] == False: cv_data = _get_wcrp_cv(source, scope, collection_id) data_factory = cfg['data_factory'] for term_name in [i for i in cv_data if i not in cfg['ommitted']]: term_data = data_factory(cv_data, term_name) if data_factory else None _create_term(collection, term_name, term_data)
def _create_collection(module, scope, collection_id, term_regex=None): """Factory method to return vocabulary collection. """ try: data = module.COLLECTION_DATA[collection_id] except (AttributeError, KeyError): data = None if collection_id.lower().replace( '_', '-') in [collection.name for collection in scope.collections]: collection = scope[collection_id.lower().replace('_', '-')] collection.description = "ESGF publisher-config CV collection: ".format( collection_id), collection.label = collection_id.title().replace('_', ' ').replace( 'Rcm', 'RCM').replace('Cmor', 'CMOR') collection.term_regex = term_regex collection.data = data return collection return pyessv.create_collection( scope, collection_id, "ESGF publisher-config CV collection: ".format(collection_id), label=collection_id.title().replace('_', ' ').replace('Rcm', 'RCM').replace( 'Cmor', 'CMOR'), term_regex=term_regex, data=data)
def _write_issue_status(scope): """Writes ES-DOC errata status terms. """ collection = pyessv.create_collection(scope, 'status', create_date=utils.CREATE_DATE, label='Status', description="Errata status codes") pyessv.create_term(collection, 'new', create_date=utils.CREATE_DATE, label='New', data={'color': '#00ff00'}) pyessv.create_term(collection, 'onhold', create_date=utils.CREATE_DATE, label='On Hold', data={'color': '#ff9900'}) pyessv.create_term(collection, 'resolved', create_date=utils.CREATE_DATE, label='Resolved', data={'color': '#0c343d'}) pyessv.create_term(collection, 'wontfix', create_date=utils.CREATE_DATE, label='Wont Fix', data={'color': '#38761d'})
def _write_pid_task_status(scope): """Writes ES-DOC PID task status terms. """ collection = pyessv.create_collection( scope, 'pid-task-status', create_date=utils.CREATE_DATE, label='Status', description="Errata PID task status codes") pyessv.create_term(collection, 'complete', create_date=utils.CREATE_DATE, label='Complete', data={'color': '#e6b8af'}) pyessv.create_term(collection, 'error', create_date=utils.CREATE_DATE, label='Error', data={'color': '#a61c00'}) pyessv.create_term(collection, 'queued', create_date=utils.CREATE_DATE, label='Queued', data={'color': '#dd7e6b'})
def _write_projects(scope): """Writes ES-DOC errata project terms. """ collection = pyessv.create_collection( scope, 'project', create_date=utils.CREATE_DATE, label='Project', description="Errata supported project codes") pyessv.create_term(collection, 'cmip5', create_date=utils.CREATE_DATE, label='CMIP5', data={ "facets": [ "wcrp:cmip5:institute", "wcrp:cmip5:experiment", "wcrp:cmip5:model", "wcrp:cmip5:variable" ], "is_pid_client": False, "is_documented": True }) pyessv.create_term(collection, 'cmip6', create_date=utils.CREATE_DATE, label='CMIP6', data={ "facets": [ "wcrp:cmip6:institution-id", "wcrp:cmip6:experiment-id", "wcrp:cmip6:source-id", "wcrp:cmip6:variable-id" ], "is_pid_client": True, "is_documented": True }) pyessv.create_term(collection, 'cordex', create_date=utils.CREATE_DATE, label='CORDEX', data={ "facets": [ "wcrp:cordex:institute", "wcrp:cordex:experiment", "wcrp:cordex:rcm-model", "wcrp:cordex:variable" ], "is_pid_client": False, "is_documented": False })
def _write_issue_severity(scope): """Writes ES-DOC errata severity terms. """ collection = pyessv.create_collection(scope, 'severity', create_date=utils.CREATE_DATE, label='Severity', description="Errata severity codes") pyessv.create_term(collection, 'low', create_date=utils.CREATE_DATE, label='Low', data={ 'color': '#e6b8af', 'sortOrdinal': 0 }) pyessv.create_term(collection, 'medium', create_date=utils.CREATE_DATE, label='Medium', data={ 'color': '#dd7e6b', 'sortOrdinal': 1 }) pyessv.create_term(collection, 'high', create_date=utils.CREATE_DATE, label='High', data={ 'color': '#cc4125', 'sortOrdinal': 2 }) pyessv.create_term(collection, 'critical', create_date=utils.CREATE_DATE, label='Critical', data={ 'color': '#a61c00', 'sortOrdinal': 3 })
def _create_collection(module, scope, collection_id, term_regex=None): """Factory method to return vocabulary collection. """ try: data = module.COLLECTION_DATA[collection_id] except (AttributeError, KeyError): data = None return pyessv.create_collection( scope, collection_id, "ESGF publisher-config CV collection: ".format(collection_id), label=collection_id.title().replace('_', ' ').replace('Rcm', 'RCM').replace( 'Cmor', 'CMOR'), term_regex=term_regex, data=data)
def create_collection_01(): """Creates & returns a test collection. """ global COLLECTION_01 if COLLECTION_01 is not None: return COLLECTION_01 COLLECTION_01 = LIB.create_collection( scope=SCOPE or create_scope(), name=COLLECTION_01_NAME, description=COLLECTION_01_DESCRIPTION, alternative_names=COLLECTION_01_ALTERNATIVE_NAMES, url=COLLECTION_01_URL) create_term_01() return COLLECTION_01
def create_collection_03(): """Creates & returns a test collection. """ global COLLECTION_03 if COLLECTION_03 is not None: return COLLECTION_03 COLLECTION_03 = LIB.create_collection( scope=SCOPE or create_scope(), name=COLLECTION_03_NAME, description=COLLECTION_03_DESCRIPTION, alternative_names=COLLECTION_03_ALTERNATIVE_NAMES, term_regex=COLLECTION_03_TERM_REGEX, url=COLLECTION_03_URL) create_term_03() return COLLECTION_03
def _write_pid_task_action(scope): """Writes ES-DOC PID task action terms. """ collection = pyessv.create_collection( scope, 'pid-task-action', create_date=utils.CREATE_DATE, label='Action', description="Errata PID task action codes") pyessv.create_term(collection, 'insert', create_date=utils.CREATE_DATE, label='Insert') pyessv.create_term(collection, 'delete', create_date=utils.CREATE_DATE, label='Delete')
def _create_collection(source, scope, collection_id, config): """Creates collection from a JSON file. """ defaults = { 'cim_document_type': None, 'cim_document_type_synonym': None, 'data_factory': None, 'is_virtual': False, 'label': None, 'ommitted': [], 'term_regex': None } defaults.update(config) cfg = defaults # Create collection. collection = pyessv.create_collection( scope, collection_id, COLLECTION_NAME_TMPL.format(collection_id), label=cfg['label'] or collection_id.title().replace('_Id', '_ID').replace('_', ' '), create_date=_CREATE_DATE, term_regex=cfg['term_regex'] or pyessv.REGEX_CANONICAL_NAME, data=None if cfg['cim_document_type'] is None else { 'cim_document_type': cfg['cim_document_type'], 'cim_document_type_synonym': cfg['cim_document_type_synonym'] }) # Load JSON data & create terms (if collection is not a virtual one). if cfg['is_virtual'] == False: cv_data = _get_cv(source, scope, collection_id) data_factory = cfg['data_factory'] for term_name in [i for i in cv_data if i not in cfg['ommitted']]: term_data = data_factory(cv_data, term_name) if data_factory else None _create_term(collection, term_name, term_data)
def _create_collection_cmip6(source, collection_type, data_factory): """Creates cmip6 collection from a WCRP JSON files. """ # Load WCRP json data. wcrp_cv_data = _get_wcrp_cv(source, collection_type, "CMIP6_") # Create collection. collection_name = collection_type.replace("_", "-") collection = pyessv.create_collection( scope=_SCOPE_CMIP6, name=collection_name, description="WCRP CMIP6 CV collection: ".format(collection_name), create_date=_CREATE_DATE) # Create terms. for name in wcrp_cv_data: pyessv.create_term( collection=collection, name=name, description=name, create_date=_CREATE_DATE, data=data_factory(wcrp_cv_data, name) if data_factory else None)
def _create_collection(source, scope, collection_id, cfg): """Creates collection from a AtMoDat JSON file. """ # Create collection. if collection_id.lower().replace('_', '-') in [collection.name for collection in scope.collections]: collection = scope[collection_id] collection.description = "AtMoDat CV collection: ".format(collection_id), collection.label = cfg['label'] or collection_id.title().replace('_Id', '_ID').replace('_', ' '), collection.create_date = _CREATE_DATE, collection.term_regex = cfg['term_regex'] or pyessv.REGEX_CANONICAL_NAME, collection.data = None if cfg['cim_document_type'] is None else { 'cim_document_type': cfg['cim_document_type'], 'cim_document_type_alternative_name': cfg['cim_document_type_alternative_name'] } else: collection = pyessv.create_collection( scope, collection_id, "AtMoDatll" " CV collection: ".format(collection_id), label=cfg['label'] or collection_id.title().replace('_Id', '_ID').replace('_', ' '), create_date=_CREATE_DATE, term_regex=cfg['term_regex'] or pyessv.REGEX_CANONICAL_NAME, data=None if cfg['cim_document_type'] is None else { 'cim_document_type': cfg['cim_document_type'], 'cim_document_type_alternative_name': cfg['cim_document_type_alternative_name'] } ) # Load JSON data & create terms (if collection is not a virtual one). if not cfg['is_virtual']: cv_data = _get_atmodat_cv(source, scope, collection_id) data_factory = cfg['data_factory'] for term_name in [i for i in cv_data if i not in cfg['ommitted']]: term_data = data_factory(cv_data, term_name) if data_factory else None _create_term(collection, term_name, term_data)
def _write_model_topic(scope): """Writes ES-DOC model topics. """ collection = pyessv.create_collection( scope, 'model-topic', create_date=utils.CREATE_DATE, label='Topics', description="Model documentation topics") pyessv.create_term(collection, 'toplevel', create_date=utils.CREATE_DATE, description='Top Level', label='Top Level') for term in pyessv.WCRP.cmip6.realm: pyessv.create_term( collection, term.raw_name, create_date=utils.CREATE_DATE, label=term.description, )