Given an interface, return a list of relation names for the current
    charm that use that interface.

    :returns: A list of relation names.
172836
def interface_to_relations(interface_name):
    
    results = []
    for role in ('provides', 'requires', 'peers'):
        results.extend(role_and_interface_to_relations(role, interface_name))
    return results
439826
def name(self):
        
        name = super(Interface, self).name
        return name if name else self.data.get('name')
1238265
def update_relations(context, namespace_separator=':'):
    """"""
    # Add any relation data prefixed with the relation type.
    relation_type = charmhelpers.core.hookenv.relation_type()
    relations = []
    context['current_relation'] = {}
    if relation_type is not None:
        relation_data = charmhelpers.core.hookenv.relation_get()
        context['current_relation'] = relation_data
        # Deprecated: the following use of relation data as keys
        # directly in the context will be removed.
        relation_data = dict(
            ("{relation_type}{namespace_separator}{key}".format(
                relation_type=relation_type,
                key=key,
                namespace_separator=namespace_separator), val)
            for key, val in relation_data.items())
        relation_data = dict_keys_without_hyphens(relation_data)
        context.update(relation_data)
        relations = charmhelpers.core.hookenv.relations_of_type(relation_type)
        relations = [dict_keys_without_hyphens(rel) for rel in relations]

    context['relations_full'] = charmhelpers.core.hookenv.relations()

    # the hookenv.relations() data structure is effectively unusable in
    # templates and other contexts when trying to access relation data other
    # than the current relation. So provide a more useful structure that works
    # with any hook.
    local_unit = charmhelpers.core.hookenv.local_unit()
    relations = {}
    for rname, rids in context['relations_full'].items():
        relations[rname] = []
        for rid, rdata in rids.items():
            data = rdata.copy()
            if local_unit in rdata:
                data.pop(local_unit)
            for unit_name, rel_data in data.items():
                new_data = {'__relid__': rid, '__unit__': unit_name}
                new_data.update(rel_data)
                relations[rname].append(new_data)
    context['relations'] = relations
360712
def interfaces_names():
    '''
    
    '''

    ret = []
    with salt.utils.winapi.Com():
        c = wmi.WMI()
        for iface in c.Win32_NetworkAdapter(NetEnabled=True):
            ret.append(iface.NetConnectionID)
    return ret
1188493
def _get_ctypes(self):
        
        ctypes = []
        for related_object in self.model._meta.get_all_related_objects():
            model = getattr(related_object, 'related_model', related_object.model)
            ctypes.append(ContentType.objects.get_for_model(model).pk)
            if model.__subclasses__():
                for child in model.__subclasses__():
                    ctypes.append(ContentType.objects.get_for_model(child).pk)
        return ctypes
1192325
def busy_connections(self):
        
        return [c for c in self.connections.values()
                if c.busy and not c.closed]
955665
def GetAttributeNames(self):
    
    attribute_names = []
    for attribute_name in iter(self.__dict__.keys()):
      # Not using startswith to improve performance.
      if attribute_name[0] == '_':
        continue
      attribute_names.append(attribute_name)

    return attribute_names
215375
def sharedInterfaces():
        
        def get(self):
            if not self.sharedInterfaceNames:
                return ()
            if self.sharedInterfaceNames == ALL_IMPLEMENTED_DB:
                I = implementedBy(self.sharedItem.__class__)
                L = list(I)
                T = tuple(L)
                return T
            else:
                return tuple(map(namedAny, self.sharedInterfaceNames.split(u',')))
        def set(self, newValue):
            self.sharedAttributeNames = _interfacesToNames(newValue)
        return get, set
283971
def _getInterfaces(self):
        
        interfaces = {}

        interfacesPath = os.path.join("application", "interface")
        interfaceList = os.listdir(interfacesPath)

        for file in interfaceList:
            interfaceDirectoryPath = os.path.join(interfacesPath, file)
            if not os.path.isdir(interfaceDirectoryPath) or file.startswith("__") or file.startswith("."):
                continue

            interfaceName = ntpath.basename(interfaceDirectoryPath)
            interfacePath = os.path.join(interfaceDirectoryPath, interfaceName) + ".py"

            if not os.path.isfile(interfacePath):
                continue

            # importing interface
            interfaceSpec = importlib.util.spec_from_file_location(
                interfaceName,
                interfacePath
            )
            interface = importlib.util.module_from_spec(interfaceSpec)
            interfaceSpec.loader.exec_module(interface)

            # checking if there is an interface in the file
            if hasattr(interface, "Service"):
                # initializing interface
                interfaceInstance = interface.Service(self)
                interfaces[interfaceName] = interfaceInstance

        return interfaces
112209
def connections(self):
        
        if not self.__connections:
            self.__connections = Connections(
                self.__connection)
        return self.__connections
295009
def getServiceDependenciesUIDs(self):
        
        deps = self.getServiceDependencies()
        deps_uids = [service.UID() for service in deps]
        return deps_uids
9829
def _get_all_refs(self, dep, handled_refs=None):
        
        if handled_refs is None:
            handled_refs = [dep]
        else:
            if dep in handled_refs:
                return []
        res = []
        if dep in self.future_values_key_item:
            res.extend(
                self.future_values_key_item[dep]["dependencies"].values())
            add = []
            for h_d in res:
                add.extend(self._get_all_refs(h_d, handled_refs))
            res.extend(add)
        return list(set(res))
1122742
def get_related_ids(self):
        
        related = self.get_related()

        full_key = related.get_qualified_key_name()

        return self.get_query().select(full_key).lists(related.get_key_name())
1224979
def relations_used(self):
        
        g = self.get_graph()
        types = set()
        for (x,y,d) in g.edges(data=True):
            types.add(d['pred'])
        return list(types)
115529
private List<Class<? extends RelationshipInterface>> getRelationClassCandidatesForRelType(final String relType) {

		List<Class<? extends RelationshipInterface>> candidates = new ArrayList();

		for (final Class<? extends RelationshipInterface> candidate : getRelationshipEntities().values()) {

			Relation rel = instantiate(candidate);

			if (rel == null) {
				continue;
			}

			if (rel.name().equals(relType)) {
				candidates.add(candidate);
			}

		}

		return candidates;

	}
150266
def role_and_interface_to_relations(role, interface_name):
    
    _metadata = metadata()
    results = []
    for relation_name, relation in _metadata.get(role, {}).items():
        if relation['interface'] == interface_name:
            results.append(relation_name)
    return results
626405
def list_relations(self):
        '''  '''
        for node in self.iter_nodes():
            for relation, target in self.relations_of(node.obj, True):
                yield node.obj, relation, target