Make a dictionary mapping the merged component names to list of template files

        Parameters
        ----------

        galkey : str
            Unique key for this ring dictionary

        Returns `model_component.GalpropMergedRingInfo`
774140
def make_ring_dict(self, galkey):
        
        galprop_rings = self.read_galprop_rings_yaml(galkey)
        galprop_run = galprop_rings['galprop_run']
        ring_limits = galprop_rings['ring_limits']
        comp_dict = galprop_rings['diffuse_comp_dict']
        remove_rings = galprop_rings.get('remove_rings', [])
        ring_dict = {}
        nring = len(ring_limits) - 1
        for source_name, source_value in comp_dict.items():
            base_dict = dict(source_name=source_name,
                             galkey=galkey,
                             galprop_run=galprop_run)
            for iring in range(nring):
                sourcekey = "%s_%i" % (source_name, iring)
                if sourcekey in remove_rings:
                    continue
                full_key = "%s_%s" % (sourcekey, galkey)
                rings = range(ring_limits[iring], ring_limits[iring + 1])
                base_dict.update(dict(ring=iring,
                                      sourcekey=sourcekey,
                                      files=self.make_ring_filelist(source_value,
                                                                    rings, galprop_run),
                                      merged_gasmap=self.make_merged_name(sourcekey,
                                                                          galkey, False)))
                ring_dict[full_key] = GalpropMergedRingInfo(**base_dict)
        self._ring_dicts[galkey] = ring_dict
        return ring_dict
1131856
def _merge_metadata_dictionaries(cls, dictionaries):
        
        # three levels of nested dictionaries!
        #   {source name: {variant: {attribute: value}}}
        combined_dictionary = {}
        for source_to_metadata_dict in dictionaries:
            for source_name, variant_to_metadata_dict in source_to_metadata_dict.items():
                combined_dictionary.setdefault(source_name, {})
                combined_source_dict = combined_dictionary[source_name]
                for variant, metadata_dict in variant_to_metadata_dict.items():
                    combined_source_dict.setdefault(variant, {})
                    combined_source_dict[variant].update(metadata_dict)
        return combined_dictionary
1306529
def get_specific_config(prefix):
    
    conf_dict = {}
    for uuid, val in cfg.CONF.get(prefix, {}).items():
        conf_dict[uuid] = dict(val)
    return conf_dict
1054326
def _co_names_from_config(self):
        
        co_names = [co[self.KEY_ENCODEABLE_NAME] for
                    co in self.config[self.KEY_CO]]

        return co_names
867718
def get_cts_metadata(self, key: str, lang: str = None) -> Literal:
        
        return self.metadata.get_single(RDF_NAMESPACES.CTS.term(key), lang)
405056
def galprop_rings_yaml(self, **kwargs):
        
        kwargs_copy = self.base_dict.copy()
        kwargs_copy.update(**kwargs)
        self._replace_none(kwargs_copy)        
        localpath = NameFactory.galprop_rings_yaml_format.format(**kwargs_copy)
        if kwargs.get('fullpath', False):
            return self.fullpath(localpath=localpath)
        return localpath
1184763
def uniquekeys(self, metakey=None):
        
        if metakey is None:
            return self._uniquekeys
        else:
            if metakey not in self.metakeys():
                raise ValueError('metakey %s does not exist' % metakey)
            return self._uniquekeys[metakey]
910087
def asDictionary(self):
        
        template = {
            "type" : "uniqueValue",
            "field1" : self._field1,
            "field2" : self._field2,
            "field3" : self._field3,
            "fieldDelimiter" : self._fieldDelimiter,
            "defaultSymbol" :  self._defaultSymbol.asDictionary,
            "defaultLabel" : self._defaultLabel,
            "uniqueValueInfos" : self._uniqueValueInfos,
            "rotationType": self._rotationType,
            "rotationExpression": self._rotationExpression
        }
        return template
450871
def unique_dimkeys(obj, default_dim='Frame'):
    
    from .ndmapping import NdMapping, item_check
    from .spaces import HoloMap
    key_dims = obj.traverse(lambda x: (tuple(x.kdims),
                                       list(x.data.keys())), (HoloMap,))
    if not key_dims:
        return [Dimension(default_dim)], [(0,)]
    dim_groups, keys = zip(*sorted(key_dims, key=lambda x: -len(x[0])))
    dgroups = [frozenset(d.name for d in dg) for dg in dim_groups]
    subset = all(g1 <= g2 or g1 >= g2 for g1 in dgroups for g2 in dgroups)
    # Find unique keys
    if subset:
        dims = merge_dimensions(dim_groups)
        all_dims = sorted(dims, key=lambda x: dim_groups[0].index(x))
    else:
        # Handle condition when HoloMap/DynamicMap dimensions do not overlap
        hmaps = obj.traverse(lambda x: x, ['HoloMap'])
        if hmaps:
            raise ValueError('When combining HoloMaps into a composite plot '
                             'their dimensions must be subsets of each other.')
        dimensions = merge_dimensions(dim_groups)
        dim_keys = {}
        for dims, keys in key_dims:
            for key in keys:
                for d, k in zip(dims, key):
                    dim_keys[d.name] = k
        if dim_keys:
            keys = [tuple(dim_keys.get(dim.name) for dim in dimensions)]
        else:
            keys = []
        return merge_dimensions(dim_groups), keys

    ndims = len(all_dims)
    unique_keys = []
    for group, keys in zip(dim_groups, keys):
        dim_idxs = [all_dims.index(dim) for dim in group]
        for key in keys:
            padded_key = create_ndkey(ndims, dim_idxs, key)
            matches = [item for item in unique_keys
                       if padded_key == tuple(k if k is None else i
                                              for i, k in zip(item, padded_key))]
            if not matches:
                unique_keys.append(padded_key)

    with item_check(False):
        sorted_keys = NdMapping({key: None for key in unique_keys},
                                kdims=all_dims).data.keys()
    return all_dims, list(sorted_keys)
138044
def get_nodekey(self, token, types=types, coll_abc=collections.abc):
        '''
        '''
        # Check the mro.
        for mro_type in type(token).__mro__:
            yield mro_type.__name__

        # Check for callability.
        if callable(token):
            yield 'callable'

        # Check for the collections.abc types.
        abc_types = (
            'Hashable',
            'Iterable',
            'Iterator',
            'Sized',
            'Container',
            'Callable',
            'Set',
            'MutableSet',
            'Mapping',
            'MutableMapping',
            'MappingView',
            'KeysView',
            'ItemsView',
            'ValuesView',
            'Sequence',
            'MutableSequence',
            'ByteString')
        for type_name in abc_types:
            type_ = getattr(coll_abc, type_name, None)
            if type_ is None:
                continue
            if isinstance(token, type_):
                yield type_name

        # Check for the standard interpreter types in the types module.
        interp_types = (
            'BuiltinFunctionType',
            'BuiltinMethodType',
            'CodeType',
            'DynamicClassAttribute',
            'FrameType',
            'FunctionType',
            'GeneratorType',
            'GetSetDescriptorType',
            'LambdaType',
            'MappingProxyType',
            'MemberDescriptorType',
            'MethodType',
            'ModuleType',
            'SimpleNamespace',
            'TracebackType')
        for type_name in interp_types:
            type_ = getattr(types, type_name, None)
            if type_ is None:
                continue
            if isinstance(token, type_):
                yield type_name
54497
def get_pk_descriptors(cls):
    """"""
    pk_fields = {
        name: descriptor
        for name, descriptor in vars_class(cls).items()
        if isinstance(descriptor, ObjectField) and is_pk_descriptor(descriptor)
    }
    alt_pk_fields = defaultdict(list)
    for name, descriptor in vars_class(cls).items():
        if isinstance(descriptor, ObjectField):
            if descriptor.alt_pk is True:
                alt_pk_fields[0].append((name, descriptor))
            elif type(descriptor.alt_pk) is int:
                alt_pk_fields[descriptor.alt_pk].append((name, descriptor))
    if len(pk_fields) == 1:
        return ((pk_fields.popitem(),), (alt_pk_fields[0],))
    elif len(pk_fields) > 1:
        unique_pk_fields = {
            name: descriptor
            for name, descriptor in pk_fields.items()
            if descriptor.pk is True
        }
        if unique_pk_fields:
            raise AttributeError(
                "more than one field is marked as unique primary key: %s" % (
                    ', '.join(sorted(pk_fields))))
        pk_descriptors = tuple(sorted((
            (name, descriptor)
            for name, descriptor in pk_fields.items()
        ), key=lambda item: item[1].pk))
        alt_pk_descriptors = tuple(
            alt_pk_fields[idx]
            for idx, (name, descriptor) in enumerate(pk_descriptors)
        )
        return pk_descriptors, alt_pk_descriptors
    else:
        return tuple(), tuple()
1106254
def map_keys(f, dct):
    
    f_dict = {}
    for k, v in dct.items():
        f_dict[f(k)] = v
    return f_dict
413910
def __get_view_tmpl(tag_key):
    '''
    
    '''
    the_view_file_4 = './templates/tmpl_{0}/tpl_view_{1}.html'.format(
        KIND_DICS['kind_' + tag_key.split('_')[-1]],
        tag_key.split('_')[1]
    )
    the_view_file_2 = './templates/tmpl_{0}/tpl_view_{1}.html'.format(
        KIND_DICS['kind_' + tag_key.split('_')[-1]],
        tag_key.split('_')[1][:2]
    )
    if os.path.exists(the_view_file_4):
        the_view_sig_str = '_{0}'.format(tag_key.split('_')[1])
    elif os.path.exists(the_view_file_2):
        the_view_sig_str = '_{0}'.format(tag_key.split('_')[1][:2])
    else:
        the_view_sig_str = ''
    return the_view_sig_str
303450
def get_filtered_keys(self, suffix, *args, **kwargs):
        

        accepted_key_types = kwargs.get('accepted_key_types', None)

        if accepted_key_types and 'set' not in accepted_key_types:
            raise ImplementationError(
                '%s can only return keys of type "set"' % self.__class__.__name__
            )

        # special "in" case: we get n keys and make an unionstore with them then return this key
        if suffix == 'in':

            args = list(args)
            values = set(args.pop())

            if not values:
                return []  # no keys

            in_keys = [
                self.get_storage_key(transform_value=False, *(args+[value]))
                for value in values
            ]

            tmp_key = unique_key(self.connection)
            self.connection.sunionstore(tmp_key, *in_keys)

            return [(tmp_key, 'set', True)]

        # do not transform because we already have the value we want to look for
        return [(self.get_storage_key(transform_value=False, *args), 'set', False)]
73695
def as_dict(self):
        
        #TODO/FIXME: add selected information
        if self.hidden:
            rdict = {}
        else:
            def_selected = self.selected()
            comps = [
                {
                    'name': comp.name,
                    'default': comp.name in self.defaults,
                    'options': comp.get_ordered_options() if isinstance(comp, Optionable) else None
                }
                for comp in self
            ]
            rdict = {
                'name': self.name,
                'required': self.required,
                'multiple': self.multiple,
                'args': self.in_name,
                'returns': self.out_name,
                'components': comps
            }
        return rdict
90009
def unique(new_cmp_dict, old_cmp_dict):
    
    newkeys = set(new_cmp_dict)
    oldkeys = set(old_cmp_dict)
    unique = newkeys - oldkeys
    unique_ldict = []
    for key in unique:
        unique_ldict.append(new_cmp_dict[key])
    return unique_ldict
1302159
def _handle_component(sourcekey, comp_dict):
        
        if comp_dict.comp_key is None:
            fullkey = sourcekey
        else:
            fullkey = "%s_%s" % (sourcekey, comp_dict.comp_key)
        srcdict = make_sources(fullkey, comp_dict)
        if comp_dict.model_type == 'IsoSource':
            print("Writing xml for %s to %s: %s %s" % (fullkey,
                                                       comp_dict.srcmdl_name,
                                                       comp_dict.model_type,
                                                       comp_dict.Spectral_Filename))
        elif comp_dict.model_type == 'MapCubeSource':
            print("Writing xml for %s to %s: %s %s" % (fullkey,
                                                       comp_dict.srcmdl_name,
                                                       comp_dict.model_type,
                                                       comp_dict.Spatial_Filename))
        SrcmapsDiffuse_SG._write_xml(comp_dict.srcmdl_name, srcdict.values())