• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sets.set函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sets.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_py_method_def

    def get_py_method_def(self, name):
        """
        Returns an array element to use in a PyMethodDef table.
        Should only be called after code generation.

        name -- python wrapper/method name
        """
        if len(self.all_wrappers) == 1 \
                and not getattr(self.all_wrappers[0], 'NEEDS_OVERLOADING_INTERFACE', False):
            return self.all_wrappers[0].get_py_method_def(name)
        else:
            self._normalize_py_method_flags()
            flags = self.all_wrappers[0].get_py_method_def_flags()
            ## detect inconsistencies in flags; they must all be the same
            if __debug__:
                for func in self.all_wrappers:
                    try:
                        assert set(func.get_py_method_def_flags()) == set(flags),\
                            ("Expected PyMethodDef flags %r, got %r"
                             % (flags, func.get_py_method_def_flags()))
                    except (TypeConfigurationError,
                            CodeGenerationError,
                            NotSupportedError):
                        pass
            docstring = None # FIXME

            assert isinstance(self.wrapper_return, basestring)
            assert isinstance(self.wrapper_actual_name, basestring)
            assert isinstance(self.wrapper_args, list)

            return "{(char *) \"%s\", (PyCFunction) %s, %s, %s }," % \
                (name, self.wrapper_actual_name, '|'.join(flags),
                 (docstring is None and "NULL" or ('"'+docstring+'"')))
开发者ID:Estoque86,项目名称:ndnSIM_MicTort,代码行数:33,代码来源:overloading.py


示例2: __init__

 def __init__(self, site=None, backend=None):
     self.query_filter = SearchNode()
     self.order_by = []
     self.models = set()
     self.boost = {}
     self.start_offset = 0
     self.end_offset = None
     self.highlight = False
     self.facets = set()
     self.date_facets = {}
     self.query_facets = []
     self.narrow_queries = set()
     self._raw_query = None
     self._raw_query_params = {}
     self._more_like_this = False
     self._mlt_instance = None
     self._results = None
     self._hit_count = None
     self._facet_counts = None
     self._spelling_suggestion = None
     
     if backend is not None:
         self.backend = backend
     else:
         self.backend = SearchBackend(site=site)
开发者ID:flebel,项目名称:django-haystack,代码行数:25,代码来源:__init__.py


示例3: do_include

def do_include(mlist, msg, msgdata, recips):
    # regular_include_lists are the other mailing lists on this mailman
    # installation whose members are included in the regular (non-digest)
    # delivery if those list addresses don't appear in To: or Cc: headers.
    if not mlist.regular_include_lists:
        return recips
    recips = set(recips)
    destinations = email.Utils.getaddresses(msg.get_all('to', []) +
                                            msg.get_all('cc', []))
    destinations = [y.lower() for x,y in destinations]
    for listname in mlist.regular_include_lists:
        listname = listname.lower()
        if listname in destinations:
            continue
        listlhs, hostname = listname.split('@')
        if listlhs == mlist.internal_name():
            syslog('error', 'Include list %s is a self reference.',
                    listname)
            continue
        try:
            slist = MailList(listlhs, lock=False)
        except MMUnknownListError:
            syslog('error', 'Include list %s not found.', listname)
            continue
        if not mm_cfg.ALLOW_CROSS_DOMAIN_SIBLING \
           and slist.host_name != hostname:
            syslog('error', 'Include list %s is not in the same domain.',
                    listname)
            continue
        srecips = set([slist.getMemberCPAddress(m)
                   for m in slist.getRegularMemberKeys()
                   if slist.getDeliveryStatus(m) == ENABLED])
        recips |= srecips
    return list(recips)
开发者ID:fumiyas,项目名称:mailman-ja-utf8-debian,代码行数:34,代码来源:CalcRecips.py


示例4: _reference_contents

    def _reference_contents(self, contents):
        "Helper method which builds internal structure from parsed contents"
        self._contents = contents
        self._ttl = int(self._contents.get("ttl", 0))
        self._return_as_map = bool(self._contents.get("return_as_map", False))
        self._legacy_dbname = self._contents.get("legacy_dbname", None)

        # reset these before doing the sql conversion because we will
        # read them there. reset these while loading so we pick up
        # changes.
        self._around = set()
        self._append = set()
        self._integer = set()
        self._options = self._contents.get("dynamic_where", {})
        for key in self._options:
            if isinstance(self._options[key], basestring):
                self._options[key] = self._convert_sql(self._options[key])
            elif isinstance(self._options[key], list):
                lines = []
                for line in self._options[key]:
                    lines.append(self._convert_sql(line))
                self._options[key] = lines
            else:
                moreopt = {}
                for kk in self._options[key]:
                    moreopt[kk] = self._convert_sql(self._options[key][kk])
                self._options[key] = moreopt
        self._base_query = self._convert_sql(self._contents["base_query"])
        self._query_suffix = self._convert_sql(self._contents.get("query_suffix", ""))
开发者ID:Kitty-xx,项目名称:imprudence,代码行数:29,代码来源:named_query.py


示例5: init_cxx

def init_cxx(self):
	if not'cc'in self.features:
		self.mappings['.c']=TaskGen.task_gen.mappings['.cxx']
	self.p_flag_vars=set(self.p_flag_vars).union(g_cxx_flag_vars)
	self.p_type_vars=set(self.p_type_vars).union(g_cxx_type_vars)
	if not self.env['CXX_NAME']:
		raise Utils.WafError("At least one compiler (g++, ..) must be selected")
开发者ID:Acidburn0zzz,项目名称:libdesktop-agnostic,代码行数:7,代码来源:cxx.py


示例6: model_dependencies

def model_dependencies(model, last_models=None, checked_models=None):
    """
    Returns a set of models this one depends on to be defined; things like
    OneToOneFields as ID, ForeignKeys everywhere, etc.
    """
    depends = {}
    checked_models = checked_models or set()
    # Get deps for each field
    for field in model._meta.fields + model._meta.many_to_many:
        depends.update(field_dependencies(field, last_models))
    # Now recurse
    new_to_check = set(depends.keys()) - checked_models
    while new_to_check:
        checked_model = new_to_check.pop()
        if checked_model == model or checked_model in checked_models:
            continue
        checked_models.add(checked_model)
        deps = model_dependencies(checked_model, last_models, checked_models)
        # Loop through dependencies...
        for dep, value in deps.items():
            # If the new dep is not already checked, add to the queue
            if (dep not in depends) and (dep not in new_to_check) and (dep not in checked_models):
                new_to_check.add(dep)
            depends[dep] = value
    return depends
开发者ID:fdl06,项目名称:medianav,代码行数:25,代码来源:startmigration.py


示例7: get_trait_names

def get_trait_names():
    global TRAIT_NAMES
    from enthought.traits.api import HasTraits
    if TRAIT_NAMES is None:
        TRAIT_NAMES = set( dir2(HasTraits()) ) - set( dir2(object()) )
    else:
        return TRAIT_NAMES
开发者ID:08saikiranreddy,项目名称:ipython,代码行数:7,代码来源:ipy_traits_completer.py


示例8: __init__

    def __init__(self,G):
        """
        Initialize from a given graph instance.  The graph G
        should have G[v][w] equal to a collection (list, set, etc)
        of the labels on edges from v to w; this allows us to
        represent multigraphs with differing labels on their
        multiedges.

        Data stored in fields of this instance:
        - self.nrg is a transformed unlabeled graph in which paths
          represent nonrepetitive paths in G
        - self.labels is a dictionary mapping vertices to their
          label sets
        """
        self.labels = {}
        for v in G:
            self.labels[v] = set()
            for w in G[v]:
                self.labels[w] = set()
        for v in G:
            for w in G[v]:
                self.labels[v].update(G[v][w])
                self.labels[w].update(G[v][w])
        self.nrg = {}
        for v in self:
            self._gadget(v,self.labels[v])
        for v in G:
            for w in G[v]:
                for L in G[v][w]:
                    self.nrg[v,L,False].add((w,L,True))
开发者ID:adamlwgriffiths,项目名称:pystream,代码行数:30,代码来源:Repetitivity.py


示例9: _gadget

 def _gadget(self,v,labels):
     """Create nonrepetitivity gadget for vertex v and given label set."""
     labels = list(labels)
     for L in labels:
         self.nrg.setdefault((v,L,True),set())
         self.nrg.setdefault((v,L,False),set())
     if len(labels) == 1:
         return
     groups = []
     n = len(labels)
     while n > 0:
         if n % 3 == 0:
             grouplen = 3
         else:
             grouplen = 2
         group = labels[n-grouplen:n]
         for L1 in group:
             for L2 in group:
                 if L1 != L2:
                     self.nrg[v,L1,True].add((v,L2,False))
         if len(labels) > 3:
             groups.append(object())
             self.nrg[v,groups[-1],False] = set([(v,L,False) for L in group])
             for L in group:
                 self.nrg[v,L,True].add((v,groups[-1],True))
         n -= grouplen
     if len(groups) > 1:
         self._gadget(v,groups)
开发者ID:adamlwgriffiths,项目名称:pystream,代码行数:28,代码来源:Repetitivity.py


示例10: update

    def update(self, *args, **kwargs):
        get_dependant_stack().push(None)
        try:
            passed_keys = set(kwargs)
            if args:
                passed_keys.update(set(args[0]))

            keys = set(self._key_subcells).intersection(passed_keys)
            originals = {}
            missing = set()
            for key in keys:
                if self.has_key(key):
                    originals[key] = self[key]
                else:
                    missing.add(key)
        finally:
            get_dependant_stack().pop(None)
        dict_update(self, *args, **kwargs)
        self.changed()
        # Find all of those that were originaly here and have changed.
        get_dependant_stack().push(None)
        try:
            changed = set()
            for key, v in originals.items():
                if v != self[key]:
                    changed.add(key)
        finally:
            get_dependant_stack().pop(None)

        for key in changed | missing:
            self._key_changed(key)
开发者ID:eliask,项目名称:SDP2011-Robotniks,代码行数:31,代码来源:celltypes.py


示例11: getRootModules

def getRootModules():
    """
    Returns a list containing the names of all the modules available in the
    folders of the pythonpath.
    """
    modules = []
    if ip.db.has_key('rootmodules'):
        return ip.db['rootmodules']
    t = time()
    store = False
    for path in sys.path:
        modules += moduleList(path)        
        if time() - t >= TIMEOUT_STORAGE and not store:
            store = True
            print "\nCaching the list of root modules, please wait!" 
            print "(This will only be done once - type '%rehashx' to " + \
            "reset cache!)"
            print
        if time() - t > TIMEOUT_GIVEUP:
            print "This is taking too long, we give up."
            print
            ip.db['rootmodules'] = []
            return []
    
    modules += sys.builtin_module_names
      
    modules = list(set(modules))
    if '__init__' in modules:
        modules.remove('__init__')
    modules = list(set(modules))
    if store:
        ip.db['rootmodules'] = modules
    return modules
开发者ID:minrk,项目名称:ipython-archive,代码行数:33,代码来源:ipy_completers.py


示例12: ant_iter

	def ant_iter(self,accept=None,maxdepth=25,pats=[],dir=False,src=True,remove=True):
		dircont=self.listdir()
		dircont.sort()
		try:
			lst=set(self.children.keys())
			if remove:
				for x in lst-set(dircont):
					del self.children[x]
		except:
			self.children={}
		for name in dircont:
			npats=accept(name,pats)
			if npats and npats[0]:
				accepted=[]in npats[0]
				node=self.make_node([name])
				isdir=os.path.isdir(node.abspath())
				if accepted:
					if isdir:
						if dir:
							yield node
					else:
						if src:
							yield node
				if getattr(node,'cache_isdir',None)or isdir:
					node.cache_isdir=True
					if maxdepth:
						for k in node.ant_iter(accept=accept,maxdepth=maxdepth-1,pats=npats,dir=dir,src=src):
							yield k
		raise StopIteration
开发者ID:HariKishan8,项目名称:Networks,代码行数:29,代码来源:Node.py


示例13: get_permissions

 def get_permissions( self ):
     permissions = set()
     for user, user_group, group, group_permission, permission in self.sandbox.recall(
         user_class + user_group_class + group_class + group_permission_class + permission_class,
         lambda u,ug,g,gp,p: u.user_id == self.user_id ):
         permissions = permissions | set( [ permission ] )
     return permissions
开发者ID:jrodrigog,项目名称:dejagears,代码行数:7,代码来源:djprovider.py


示例14: old_init

    def old_init(self):
        try:
            ads = set()
        except NameError:
            # for Python 2.3 
            from sets import Set as set
            ads = set()

        positions = []
        all_comments = self.ballot.comments.all().select_related('ad')
        for p in self.ballot.positions.all().select_related('ad'):
            po = create_position_object(self.ballot, p, all_comments)
            #if not self.ballot_active:
            #    if 'is_old_ad' in po:
            #        del po['is_old_ad']
            ads.add(str(p.ad))
            positions.append(po)
        for c in all_comments:
            if (str(c.ad) not in ads) and c.ad.is_current_ad():
                positions.append({'has_text':True,
                                  'comment_text':c.text,
                                  'comment_date':c.date,
                                  'comment_revision':str(c.revision),
                                  'ad_name':str(c.ad),
                                  'ad_username': c.ad.login_name,
                                  'position':'No Record',
                                  'is_old_ad':False})
                ads.add(str(c.ad))
        if self.ballot_active:
            for ad in IESGLogin.active_iesg():
                if str(ad) not in ads:
                    positions.append(dict(ad_name=str(ad),
                                          ad_username=ad.login_name,
                                          position="No Record"))
        self._positions = positions
开发者ID:mcr,项目名称:ietfdb,代码行数:35,代码来源:idrfc_wrapper.py


示例15: _parse_filename

    def _parse_filename(self, filename):
        """Returns a messages file name components

        Receives the file name (without path) of a msg.  Usual format is
        '<%d_%d.%d.%s>,U=<%d>,FMD5=<%s>:2,<FLAGS>' (pointy brackets
        denoting the various components).

        If FMD5 does not correspond with the current folder MD5, we will
        return None for the UID & FMD5 (as it is not valid in this
        folder).  If UID or FMD5 can not be detected, we return `None`
        for the respective element.  If flags are empty or cannot be
        detected, we return an empty flags list.

        :returns: (prefix, UID, FMD5, flags). UID is a numeric "long"
            type. flags is a set() of Maildir flags"""
        prefix, uid, fmd5, flags = None, None, None, set()
        prefixmatch = self.re_prefixmatch.match(filename)
        if prefixmatch:
            prefix = prefixmatch.group(1)
        folderstr = ',FMD5=%s' % self._foldermd5
        foldermatch = folderstr in filename
        # If there was no folder MD5 specified, or if it mismatches,
        # assume it is a foreign (new) message and ret: uid, fmd5 = None, None
        if foldermatch:
            uidmatch = re_uidmatch.search(filename)
            if uidmatch:
                uid = long(uidmatch.group(1))
        flagmatch = self.re_flagmatch.search(filename)
        if flagmatch:
            # Filter out all lowercase (custom maildir) flags. We don't
            # handle them yet.
            flags = set((c for c in flagmatch.group(1) if not c.islower()))
        return prefix, uid, fmd5, flags
开发者ID:aroig,项目名称:offlineimap,代码行数:33,代码来源:Maildir.py


示例16: run

    def run(self):
        self.init(database = True, write = False)
        upgradable_pkgs = pisi.api.list_upgradable()

        component = ctx.get_option('component')
        if component:
            #FIXME: PiSi api is insufficient to do this
            from sets import Set as set
            component_pkgs = self.componentdb.get_union_packages(component, walk=True)
            upgradable_pkgs = list(set(upgradable_pkgs) & set(component_pkgs))

        if not upgradable_pkgs:
            ctx.ui.info(_('No packages to upgrade.'))

        upgradable_pkgs.sort()
        if self.options.install_info:
            ctx.ui.info(_('Package Name     |St|   Version|  Rel.| Build|  Distro|             Date'))
            print         '========================================================================'
        for pkg in upgradable_pkgs:
            package = self.installdb.get_package(pkg)
            inst_info = self.installdb.get_info(pkg)
            if self.options.long:
                ctx.ui.info(package)
                print inst_info
            elif self.options.install_info:
                ctx.ui.info('%-15s | %s ' % (package.name, inst_info.one_liner()))
            else:
                ctx.ui.info('%15s - %s ' % (package.name, package.summary))
开发者ID:dhirajkhatiwada1,项目名称:uludag,代码行数:28,代码来源:listupgrades.py


示例17: _merge_sanity_check

 def _merge_sanity_check(self, other):
     super(ValuesQuerySet, self)._merge_sanity_check(other)
     if (set(self.extra_names) != set(other.extra_names) or
             set(self.field_names) != set(other.field_names) or
             self.aggregate_names != other.aggregate_names):
         raise TypeError("Merging '%s' classes must involve the same values in each case."
                 % self.__class__.__name__)
开发者ID:faridani,项目名称:Mturk-Tracker,代码行数:7,代码来源:query.py


示例18: walk_tagged_names

    def walk_tagged_names(self, names, tags, predicate):
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        args = [self.tagspace]
        sql = 'SELECT DISTINCT name, tag FROM tags WHERE tagspace=%s'
        if names:
            sql += ' AND name IN (' + ', '.join(['%s' for n in names]) + ')'
            args += names
        if tags:
            sql += ' AND name in (SELECT name FROM tags WHERE tag in (' + ', '.join(['%s' for t in tags]) + '))'
            args += tags
        sql += " ORDER BY name"
        cursor.execute(sql, args)

        tags = set(tags)
        current_name = None
        name_tags = set()
        for name, tag in cursor:
            if current_name != name:
                if current_name is not None:
                    if predicate(current_name, name_tags):
                        yield (current_name, name_tags)
                name_tags = set([tag])
                current_name = name
            else:
                name_tags.add(tag)
        if current_name is not None and predicate(current_name, name_tags):
            yield (current_name, name_tags)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:api.py


示例19: test_regression_site_kwarg

 def test_regression_site_kwarg(self):
     mock_index_site = SearchSite()
     mock_index_site.register(MockModel)
     mock_index_site.register(AnotherMockModel)
     
     bsqs = SearchQuerySet(site=mock_index_site)
     self.assertEqual(set(bsqs.query.backend.site.get_indexed_models()), set([MockModel, AnotherMockModel]))
开发者ID:lachezar-zz,项目名称:django-haystack,代码行数:7,代码来源:query.py


示例20: get_tags

 def get_tags(self, names=[], tagspaces=[], operation='union', detailed=False):
     """ Get tags with the given names from the given tagspaces.
         'operation' is the union or intersection of all tags on
         names. If detailed, return a set of
         {tag:set([(tagspace, name), ...])}, otherwise return a set of
         tags. """
     assert type(names) in (list, tuple, set)
     tagspaces = tagspaces or self.tagspaces
     seed_set = True
     all_tags = set()
     tagged_names = {}
     for tagspace, name, tags in self.walk_tagged_names(names=names, tagspaces=tagspaces):
         for tag in tags:
             tagged_names.setdefault(tag, set()).add((tagspace, name))
         if operation == 'intersection':
             if seed_set:
                 seed_set = False
                 all_tags.update(tags)
             else:
                 all_tags.intersection_update(tags)
                 if not all_tags:
                     return detailed and {} or set()
         else:
             all_tags.update(tags)
     if detailed:
         out_tags = {}
         for tag in all_tags:
             out_tags[tag] = tagged_names[tag]
         return out_tags
     else:
         return all_tags
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:api.py



注:本文中的sets.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python settings._函数代码示例发布时间:2022-05-27
下一篇:
Python sets.frozenset函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap