本文整理汇总了Python中mailpile.commands.Command类的典型用法代码示例。如果您正苦于以下问题:Python Command类的具体用法?Python Command怎么用?Python Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Command类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _success
def _success(self, message, result=None):
return Command._success(self, message, result=self._result(result))
示例2: state_as_query_args
def state_as_query_args(self):
try:
return self._search_state
except (AttributeError, NameError):
return Command.state_as_query_args(self)
示例3: _error
def _error(self, message, info=None, result=None):
return Command._error(self, message,
info=info, result=self._result(result))
示例4: _error
def _error(self, message, info=None, result=None):
global LOGIN_FAILURES
LOGIN_FAILURES.append(int(time.time()))
return Command._error(self, message,
info=info, result=self._result(result))
示例5: cache_id
def cache_id(self, *args, **kwargs):
if self._emails:
return ""
return Command.cache_id(self, *args, **kwargs)
示例6: _starting
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]
示例7: _starting
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]
示例8: __init__
def __init__(self, *args, **kwargs):
Command.__init__(self, *args, **kwargs)
self._email_views = []
self._email_view_pairs = {}
self._emails = []
示例9: cache_id
def cache_id(self, *args, **kwargs):
if self._emails or self.session.search_index:
return ''
return Command.cache_id(self, *args, **kwargs)
示例10: _idx
def _idx(self, **kwargs):
return self.session.search_index or Command._idx(self)
示例11: MailpileVCard
session.main = True
config.clean_tempfile_dir()
config.load(session)
session.config=cfg
vcard = MailpileVCard()
vcard.kind='profile'
with open('/tmp/mail', 'rb') as fort3f3:mail=fort3f3.read()
with open('/tmp/fn', 'rb') as fort2f3:fn=fort2f3.read()
mail.replace("\n", "")
fn.replace("\n","")
mail=''.join(mail.splitlines())
fn=''.join(fn.splitlines())
data= {'name': [fn], 'email': [mail],'route-protocol':['smtp'],'route-host':['::1'],'route-port':['25'],'route-auth_type':['none']}
command=Command(session,data=data)
command.session=session
addvcard=AddVCard(VCardCommand(command))
addvcard.session=session
profile=AddProfile(addvcard)
profile.session=session;
profile.data=data
vcard.config=cfg
print "before update"
print mail
print fn
profile._update_vcard_from_post(vcard)
print "after update"
#profile._create_new_key(vcard, "RSA4096",session)