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


Python Command._starting方法代码示例

本文整理汇总了Python中mailpile.commands.Command._starting方法的典型用法代码示例。如果您正苦于以下问题:Python Command._starting方法的具体用法?Python Command._starting怎么用?Python Command._starting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mailpile.commands.Command的用法示例。


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

示例1: _starting

# 需要导入模块: from mailpile.commands import Command [as 别名]
# 或者: from mailpile.commands.Command import _starting [as 别名]
    def _starting(self):
        Command._starting(self)
        session, idx = self.session, self._idx()
        self._search_args = args = []

        self.context = self.data.get('context', [None])[0]
        if self.context:
            args += self.session.searched

        def nq(t):
            p = t[0] if (t and t[0] in '-+') else ''
            t = t[len(p):]
            if t.startswith('tag:') or t.startswith('in:'):
                try:
                    t = 'in:%s' % session.config.get_tag(t.split(':')[1]).slug
                except (IndexError, KeyError, TypeError):
                    pass
            return p+t


        args += [a for a in list(nq(a) for a in self.args) if a not in args]
        for q in self.data.get('q', []):
            ext = [nq(a) for a in q.split()]
            args.extend([a for a in ext if a not in args])

        # Query refinements...
        qrs = []
        for qr in self.data.get('qr', []):
            qrs.extend(nq(a) for a in qr.split())
        args.extend(qrs)

        for order in self.data.get('order', []):
            session.order = order

        num = def_num = session.config.prefs.num_results
        d_start = int(self.data.get('start', [0])[0])
        d_end = int(self.data.get('end', [0])[0])
        if d_start and d_end:
            args[:0] = ['@%s' % d_start]
            num = d_end - d_start + 1
        elif d_start:
            args[:0] = ['@%s' % d_start]
        elif d_end:
            args[:0] = ['@%s' % (d_end - num + 1)]

        start = 0
        while args and args[0].startswith('@'):
            spoint = args.pop(0)[1:]
            try:
                start = int(spoint) - 1
            except ValueError:
                raise UsageError(_('Weird starting point: %s') % spoint)

        session.order = session.order or session.config.prefs.default_order
        self._start = start
        self._num = num
        self._search_state = {
            'q': [q for q in args if q not in qrs],
            'qr': qrs,
            'order': [session.order],
            'start': [str(start + 1)] if start else [],
            'end': [str(start + num)] if (num != def_num) else []
        }
        if self.context:
            self._search_state['context'] = [self.context]
开发者ID:paulfurley,项目名称:Mailpile,代码行数:67,代码来源:search.py

示例2: _starting

# 需要导入模块: from mailpile.commands import Command [as 别名]
# 或者: from mailpile.commands.Command import _starting [as 别名]
    def _starting(self):
        Command._starting(self)
        session, idx = self.session, self._idx()
        self._search_args = args = []

        self._email_views = self.data.get("view", [])
        self._email_view_pairs = dict((m.split("/")[0], m.split("/")[-1]) for m in self._email_views)
        self._emails = []

        self.context = self.data.get("context", [None])[0]
        if self.context:
            args += self.session.searched

        def nq(t):
            p = t[0] if (t and t[0] in "-+") else ""
            t = t[len(p) :]
            if t.startswith("tag:") or t.startswith("in:"):
                try:
                    raw_tag = session.config.get_tag(t.split(":")[1])
                    if raw_tag and raw_tag.hasattr(slug):
                        t = "in:%s" % raw_tag.slug
                except (IndexError, KeyError, TypeError):
                    pass
            return p + t

        args += [a for a in list(nq(a) for a in self.args) if a not in args]
        for q in self.data.get("q", []):
            ext = [nq(a) for a in q.split()]
            args.extend([a for a in ext if a not in args])

        # Query refinements...
        qrs = []
        for qr in self.data.get("qr", []):
            qrs.extend(nq(a) for a in qr.split())
        args.extend(qrs)

        for order in self.data.get("order", []):
            session.order = order

        num = def_num = session.config.prefs.num_results
        d_start = int(self.data.get("start", [0])[0])
        d_end = int(self.data.get("end", [0])[0])
        if d_start and d_end:
            args[:0] = ["@%s" % d_start]
            num = d_end - d_start + 1
        elif d_start:
            args[:0] = ["@%s" % d_start]
        elif d_end:
            args[:0] = ["@%s" % (d_end - num + 1)]

        start = 0
        self._default_position = True
        while args and args[0].startswith("@"):
            spoint = args.pop(0)[1:]
            try:
                start = int(spoint) - 1
                self._default_position = False
            except ValueError:
                raise UsageError(_("Weird starting point: %s") % spoint)

        session.order = session.order or session.config.prefs.default_order
        self._start = start
        self._num = num
        self._search_state = {
            "q": [q for q in args if q not in qrs],
            "qr": qrs,
            "order": [session.order],
            "start": [str(start + 1)] if start else [],
            "view": self._email_views,
            "end": [str(start + num)] if (num != def_num) else [],
        }
        if self.context:
            self._search_state["context"] = [self.context]
开发者ID:JackDca,项目名称:Mailpile,代码行数:75,代码来源:search.py


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