Esempio n. 1
0
def get_categories(facets):
    categories = []
    i = 0
    for i, facet in facets:
        facet_type = 'enum'
        if facet in ['member_id', 'variable_id']:
            facet_type = 'string'
        if facet not in ['version']:
            categories.append((facet, facet_type, 'true', 'true', str(i)))
    for facet in EXTRACT_GLOBAL_NC:
        facet_type = 'string'
        if facet in ['sub_experiment_id']:
            facet_type = 'enum'
        categories.append((facet, facet_type, 'false', 'true', str(i)))
        i += 1
    categories.append(('experiment_title', 'string', 'false', 'true', str(i)))
    categories.append(('model_cohort', 'string', 'true', 'true', str(i+1)))
    categories.append(('project', 'string', 'false', 'true', str(i+2)))
    categories.append(('description', 'text', 'false', 'false', '99'))
    categories = tuple([build_line(category, length=lengths(categories), indent=True) for category in categories])
    return build_line(categories, sep='\n')
Esempio n. 2
0
def declare_map(config, facet):
    maps = []
    if config.has_option('maps'):
        maps = map(str.strip, config.get('maps').split(','))
    maps.append('{}_map'.format(facet))
    config.set('maps', build_line(tuple(maps), sep=', '))
Esempio n. 3
0
    maps.append('{}_map'.format(facet))
    config.set('maps', build_line(tuple(maps), sep=', '))


if __name__ == "__main__":
    args = get_args()
    auth = HTTPBasicAuth(
        args.gh_user,
        args.gh_password) if args.gh_user and args.gh_password else None
    config = SectionParser(section='project:{}'.format(args.project))
    # Get all facet keys from format elements
    facets = get_facets()
    config.set('categories', get_categories(facets), newline=True)
    defaults = [('project', 'CMIP6')]
    defaults = tuple([
        build_line(default, length=lengths(defaults), indent=True)
        for default in sorted(defaults)
    ])
    config.set('category_defaults',
               build_line(defaults, sep='\n'),
               newline=True)
    config.set('filename_format', FILENAME_FORMAT)
    config.set('directory_format', DIRECTORY_FORMAT)
    config.set('dataset_id', DATASET_ID)
    config.set('dataset_name_format', DATASET_FORMAT)
    config.set('mip_era_options', MIP_ERA)
    categories = config.get_options_from_table('categories')
    rank = 1
    while rank in map(int, zip(*categories)[4]):
        facet, facet_type, mandatory, _, _ = categories[rank]
        if strtobool(mandatory):
Esempio n. 4
0
    if config.has_option('maps'):
        maps = map(str.strip, config.get('maps').split(','))
    maps.append('{}_map'.format(facet))
    config.set('maps', build_line(tuple(maps), sep=', '))


if __name__ == "__main__":
    args = get_args()
    auth = HTTPBasicAuth(args.gh_user, args.gh_password) if args.gh_user and args.gh_password else None
    config = SectionParser(section='project:{}'.format(args.project))
    # Get all facet keys from format elements
    facets = get_facets()
    config.set('categories', get_categories(facets), newline=True)
    defaults = [('project', 'CMIP6')]
    defaults = tuple(
        [build_line(default, length=lengths(defaults), indent=True) for default in sorted(defaults)])
    config.set('category_defaults', build_line(defaults, sep='\n'), newline=True)
    config.set('filename_format', FILENAME_FORMAT)
    config.set('directory_format', DIRECTORY_FORMAT)
    config.set('dataset_id', DATASET_ID)
    config.set('dataset_name_format', DATASET_FORMAT)
    config.set('mip_era_options', MIP_ERA)
    categories = config.get_options_from_table('categories')
    rank = 1
    while rank in map(int, zip(*categories)[4]):
        facet, facet_type, mandatory, _, _ = categories[rank]
        if strtobool(mandatory):
            if facet_type == 'enum':
                if not facet == 'variable_id':
                    content = get_json_content(facet, auth=auth, devel=args.devel)
                if facet == 'experiment_id':