当前位置: 首页>>代码示例>>Python>>正文


Python pep.iteritems函数代码示例

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


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

示例1: __call__

 def __call__(self, html, fields, context):
     html.data("fields", len(fields))
     for name, value in iteritems(fields):
         if is_string(value):
             html.append(Html("div", value, field=name))
         else:
             html.append(Html("div", field=name, value=value))
开发者ID:pombredanne,项目名称:lux,代码行数:7,代码来源:contents.py

示例2: _auth_header

 def _auth_header(self, type, **options):
     """Convert the stored values into a WWW-Authenticate header."""
     return '%s %s' % (type.title(), ', '.join((
         '%s=%s' % (key, quote_header_value(
             value, allow_token=key not in _require_quoting))
         for key, value in iteritems(options)
     )))
开发者ID:BazookaShao,项目名称:pulsar,代码行数:7,代码来源:auth.py

示例3: stream

 def stream(self, whitespace=''):
     '''This function convert the :class:`css` element into a string.'''
     # First we execute mixins
     if self.rendered:
         raise RuntimeError('%s already rendered' % self)
     self.rendered = True
     children = self._children
     self._children = OrderedDict()
     for tag, clist in iteritems(children):
         for c in clist:
             c._parent = None
             s = c.set_parent(self)
             if s:   # the child (mixin) has return a string, added it.
                 yield (None, s)
     data = []
     for k, v in self._attributes:
         v = as_value(v)
         if v is not None:
             data.append('%s    %s: %s;' % (whitespace, k, v))
     if data:
         yield (self.tag, '\n'.join(data))
     # yield Mixins and children
     for child_list in itervalues(self._children):
         if isinstance(child_list, list):
             child = child_list[0]
             for c in child_list[1:]:
                 child.extend(c)
             for s in child.stream(whitespace):
                 yield s
         else:
             yield None, child_list
开发者ID:pombredanne,项目名称:lux,代码行数:31,代码来源:base.py

示例4: stream_mapping

def stream_mapping(value, request=None):
    result = {}
    for key, value in iteritems(value):
        if isinstance(value, AsyncString):
            value = value.render(request)
        result[key] = value
    return multi_async(result)
开发者ID:imclab,项目名称:pulsar,代码行数:7,代码来源:content.py

示例5: zadd

    def zadd(self, name, *args, **kwargs):
        """
        Set any number of score, element-name pairs to the key ``name``. Pairs
        can be specified in two ways:

        As ``*args``, in the form of::

            score1, name1, score2, name2, ...

        or as ``**kwargs``, in the form of::

            name1=score1, name2=score2, ...

        The following example would add four values to the 'my-key' key::

            client.zadd('my-key', 1.1, 'name1', 2.2, 'name2',
                        name3=3.3, name4=4.4)
        """
        pieces = []
        if args:
            if len(args) % 2 != 0:
                raise ValueError("ZADD requires an equal number of "
                                 "values and scores")
            pieces.extend(args)
        for pair in iteritems(kwargs):
            pieces.append(pair[1])
            pieces.append(pair[0])
        return self.execute_command('ZADD', name, *pieces)
开发者ID:axisofentropy,项目名称:pulsar,代码行数:28,代码来源:client.py

示例6: apply_content

 def apply_content(self, elem, content):
     elem.data({'id': content.id, 'content_type': content.content_type})
     for name, value in chain((('title', content.title),
                               ('keywords', content.keywords)),
                              iteritems(content.data)):
         if not is_string(value):
             elem.data(name, value)
         elif value:
             elem.append(Html('div', value, field=name))
开发者ID:pombredanne,项目名称:lux,代码行数:9,代码来源:grid.py

示例7: _

 def _():
     for data, tags in iteritems(od):
         if tags:
             yield ',\n'.join(('%s%s' % (whitespace, t) for t in tags)
                              ) + ' {'
             yield data
             yield whitespace + '}\n'
         else:
             yield data
开发者ID:pombredanne,项目名称:lux,代码行数:9,代码来源:base.py

示例8: _spawn_actor

def _spawn_actor(cls, monitor, cfg=None, name=None, aid=None, **kw):
    # Internal function which spawns a new Actor and return its
    # ActorProxyMonitor.
    # *cls* is the Actor class
    # *monitor* can be either the ariber or a monitor
    kind = None
    if issubclass(cls, PoolMixin):
        kind = 'monitor'
    if monitor:
        params = monitor.actorparams()
        name = params.pop('name', name)
        aid = params.pop('aid', aid)
        cfg = params.pop('cfg', cfg)

    # get config if not available
    if cfg is None:
        if monitor:
            cfg = monitor.cfg.copy()
        else:
            cfg = Config()

    if not monitor:  # monitor not available, this is the arbiter
        if kind != 'monitor':
            raise TypeError('class %s not a valid monitor' % cls)
        kind = 'arbiter'
        params = {}
        if not cfg.exc_id:
            if not aid:
                aid = gen_unique_id()[:8]
            cfg.set('exc_id', aid)
    #
    for key, value in iteritems(kw):
        if key in cfg.settings:
            cfg.set(key, value)
        else:
            params[key] = value
    #
    if monitor:
        if not kind:
            if not issubclass(cls, Actor):
                raise TypeError('Class %s not a valid actor.' % cls)
            kind = cfg.concurrency
    if not kind:
        raise TypeError('Cannot spawn class %s. not a valid concurrency.'
                        % cls)
    actor_proxy = concurrency(kind, cls, monitor, cfg, name=name,
                              aid=aid, **params)
    # Add to the list of managed actors if this is a remote actor
    if isinstance(actor_proxy, Actor):
        return actor_proxy
    else:
        actor_proxy.monitor = monitor
        monitor.managed_actors[actor_proxy.aid] = actor_proxy
        future = actor_proxy_future(actor_proxy)
        actor_proxy.start()
        return future
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:56,代码来源:monitor.py

示例9: stream_mapping

def stream_mapping(value, request=None):
    result = {}
    async = False
    for key, value in iteritems(value):
        if isinstance(value, AsyncString):
            value = value.content(request)
        value = maybe_async(value)
        async = async or isinstance(value, Deferred)
        result[key] = value
    return multi_async(result) if async else result
开发者ID:BazookaShao,项目名称:pulsar,代码行数:10,代码来源:content.py

示例10: manage_actors

    def manage_actors(self, stop=False):
        '''Remove :class:`Actor` which are not alive from the
:class:`PoolMixin.managed_actors` and return the number of actors still alive.

:parameter stop: if ``True`` stops all alive actor.
'''
        alive = 0
        if self.managed_actors:
            for aid, actor in list(iteritems(self.managed_actors)):
                alive += self.manage_actor(actor, stop)
        return alive
开发者ID:elimisteve,项目名称:pulsar,代码行数:11,代码来源:monitor.py

示例11: initials

    def initials(cls):
        '''Iterator over initial field values.

        Check the :attr:`Field.initial` attribute for more information.
        This class method can be useful when using forms outside web
        applications.
        '''
        for name, field in iteritems(cls.base_fields):
            initial = field.get_initial(cls)
            if initial is not None:
                yield name, initial
开发者ID:pombredanne,项目名称:lux,代码行数:11,代码来源:form.py

示例12: poll

 def poll(self, timeout=None):
     readable, writeable, errors = _select(
         self.read_fds, self.write_fds, self.error_fds, timeout)
     events = {}
     for fd in readable:
         events[fd] = events.get(fd, 0) | READ
     for fd in writeable:
         events[fd] = events.get(fd, 0) | WRITE
     for fd in errors:
         events[fd] = events.get(fd, 0) | ERROR
     return list(iteritems(events))
开发者ID:BazookaShao,项目名称:pulsar,代码行数:11,代码来源:pollers.py

示例13: update

 def update(self, *args, **kwargs):
     if len(args) == 1:
         iterable = args[0]
         if isinstance(iterable, Mapping):
             iterable = iteritems(iterable)
         super(Model, self).update(((mstr(k), v)
                                    for k, v in iterable))
         self._modified = 1
     elif args:
         raise TypeError('expected at most 1 arguments, got %s' % len(args))
     if kwargs:
         super(Model, self).update(**kwargs)
         self._modified = 1
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:13,代码来源:model.py

示例14: commit

    def commit(self):
        '''Commit the transaction.

        This method can be invoked once only otherwise an
        :class:`.InvalidOperation` occurs.

        :return: a :class:`~asyncio.Future` which results in this transaction
        '''
        if self._executed is None:
            fut = multi_async((store.execute_transaction(commands) for
                               store, commands in iteritems(self._commands)))
            self._executed = fut
            return self._executed
        else:
            raise InvalidOperation('Transaction already executed.')
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:15,代码来源:transaction.py

示例15: data

 def data(self, *args):
     '''Add or retrieve data values for this :class:`Html`.'''
     data = self._data
     if not args:
         return data or {}
     result, adding = self._attrdata('data', *args)
     if adding:
         if data is None:
             self._extra['data'] = {}
         add = self._visitor.add_data
         for key, value in iteritems(result):
             add(self, key, value)
         return self
     else:
         return result
开发者ID:imclab,项目名称:pulsar,代码行数:15,代码来源:content.py


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