示例#1
0
    def get_checksum_type(self):
        """
        Gets the checksum type to use.
        Be careful to Exception constants by reading two different sections.

        :returns: The checksum type
        :rtype: *str*

        """
        _cfg = SectionParser(section='DEFAULT', directory=self.config_dir)
        if _cfg.has_option('checksum', section='DEFAULT'):
            checksum_type = _cfg.get_options_from_table(
                'checksum')[0][1].lower()
        else:  # Use SHA256 as default because esg.ini not mandatory in configuration directory
            checksum_type = 'sha256'
        if checksum_type not in checksum_types:
            raise InvalidChecksumType(checksum_type)
        return checksum_type
示例#2
0
文件: json2ini.py 项目: hgscal/config
 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':
                 # experiment_id_options
                 values = content.keys()
                 config.set('{}_options'.format(facet),
                            build_line(tuple(sorted(values)), sep=', '))
                 # experiment_description_map