コード例 #1
0
 def list_messages(self, terminal, verbose=1):
     if 0 < verbose:
         terminal.notice('Selection: %s' % self.description())
     n = 0
     self.focus = max(self.focus, self.window_start)
     try:
         for (i, doc) in self.iter(self.window_start):
             n += 1
             if n == self.window_size:
                 self.focus = min(self.focus, i)
             if 0 <= verbose:
                 message.show_digest(terminal, i, i == self.focus, doc,
                                     self, doc.get_labels())
             else:
                 terminal.notice(str(i))
             self.window_end = i
             if n == self.window_size: break
         if 0 < verbose and n:
             (self.finished, self.nresults) = self.status()
             results = '%d-%d of ' % (self.window_start + 1,
                                      self.window_end + 1)
             if not self.finished:
                 results += 'about '
             results += '%d messages.' % self.nresults
             terminal.display(results + '\n')
     except KeyboardInterrupt:
         pass
     return n
コード例 #2
0
ファイル: kernel.py プロジェクト: yasusii/shaling
 def list_messages(self, terminal, verbose=1):
   if 0 < verbose:
     terminal.notice('Selection: %s' % self.description())
   n = 0
   self.focus = max(self.focus, self.window_start)
   try:
     for (i,doc) in self.iter(self.window_start):
       n += 1
       if n == self.window_size:
         self.focus = min(self.focus, i)
       if 0 <= verbose:
         message.show_digest(terminal, i, i == self.focus,
                             doc, self, doc.get_labels())
       else:
         terminal.notice(str(i))
       self.window_end = i
       if n == self.window_size: break
     if 0 < verbose and n:
       (self.finished, self.nresults) = self.status()
       results = '%d-%d of ' % (self.window_start+1, self.window_end+1)
       if not self.finished:
         results += 'about '
       results += '%d messages.' % self.nresults
       terminal.display(results+'\n')
   except KeyboardInterrupt:
     pass
   return n
コード例 #3
0
 def cmd_show(self, args):
     'usage: show [-q] [-l)ist] [-a)ll] [-h)eaders] [-c charset] [-P)rev|-N)ext] msg:part ...'
     try:
         (opts, args) = getopt(args, 'qlahc:PN')
     except GetoptError:
         raise Kernel.ShowUsage()
     #
     verbose = 1
     dolist = False
     showall = False
     headerlevel = 1
     charset = None
     rel = 0
     for (k, v) in opts:
         if k == '-q': verbose = 0
         elif k == '-l': dolist = True
         elif k == '-a': showall = True
         elif k == '-h': headerlevel = 2
         elif k == '-c': charset = v
         elif k == '-P': rel = -1
         elif k == '-N': rel = +1
     #
     (docs, args) = self.get_messages(args or ['.'], rel)
     if args:
         self.terminal.warning('Arguments ignored: %r' % args)
     for (i, doc, part) in docs:
         if dolist:
             message.show_digest(self.terminal, i, False, doc,
                                 self.get_selection(), doc.get_labels())
             continue
         if part == None:
             message.show_message(self.terminal, i, doc,
                                  self.get_selection(), showall, showall,
                                  headerlevel, verbose)
             continue
         try:
             message.show_mime_part(self.terminal, doc.get_msg(0), part,
                                    headerlevel, charset)
         except MessagePartNotFoundError:
             raise Kernel.ValueError('Message part not found.')
     return
コード例 #4
0
ファイル: kernel.py プロジェクト: yasusii/shaling
 def cmd_show(self, args):
   'usage: show [-q] [-l)ist] [-a)ll] [-h)eaders] [-c charset] [-P)rev|-N)ext] msg:part ...'
   try:
     (opts, args) = getopt(args, 'qlahc:PN')
   except GetoptError:
     raise Kernel.ShowUsage()
   #
   verbose = 1
   dolist = False
   showall = False
   headerlevel = 1
   charset = None
   rel = 0
   for (k,v) in opts:
     if k == '-q': verbose = 0
     elif k == '-l': dolist = True
     elif k == '-a': showall = True
     elif k == '-h': headerlevel = 2
     elif k == '-c': charset = v
     elif k == '-P': rel = -1
     elif k == '-N': rel = +1
   #
   (docs, args) = self.get_messages(args or ['.'], rel)
   if args:
     self.terminal.warning('Arguments ignored: %r' % args)
   for (i,doc,part) in docs:
     if dolist:
       message.show_digest(self.terminal, i, False,
                           doc, self.get_selection(), doc.get_labels())
       continue
     if part == None:
       message.show_message(self.terminal, i, doc, self.get_selection(),
                            showall, showall, headerlevel, verbose)
       continue
     try:
       message.show_mime_part(self.terminal, doc.get_msg(0),
                              part, headerlevel, charset)
     except MessagePartNotFoundError:
       raise Kernel.ValueError('Message part not found.')
   return
コード例 #5
0
            ruleset = importer.RuleSet(rules)
        except importer.RuleSetSyntaxError, e:
            raise Kernel.ValueError('Invalid ruleset: %s' % e)
        corpus = self.get_selection().get_corpus()
        corpus.set_writable()
        for (i, doc, part) in docs:
            label_add = set(ruleset.apply_msg(doc.get_msg()))
            if dryrun:
                if not reset:
                    label_add.update(doc.get_labels())
            else:
                if reset:
                    corpus.del_message_label(doc.loc, doc.get_labels())
                corpus.add_message_label(doc.loc, label_add)
            if dryrun or verbose:
                message.show_digest(self.terminal, i, False, doc,
                                    self.get_selection(), label_add)
        return

    # cmd_sel
    def cmd_sel(self, args):
        'usage: sel [-q] [selection]'
        try:
            (opts, args) = getopt(args, 'q')
        except GetoptError:
            raise Kernel.ShowUsage()
        #
        verbose = 1
        for (k, v) in opts:
            if k == '-q': verbose = 0
        #
        selections = self.list_selections()
コード例 #6
0
ファイル: kernel.py プロジェクト: yasusii/shaling
      ruleset = importer.RuleSet(rules)
    except importer.RuleSetSyntaxError, e:
      raise Kernel.ValueError('Invalid ruleset: %s' % e)
    corpus = self.get_selection().get_corpus()
    corpus.set_writable()
    for (i,doc,part) in docs:
      label_add = set(ruleset.apply_msg(doc.get_msg()))
      if dryrun:
        if not reset:
          label_add.update(doc.get_labels())
      else:
        if reset:
          corpus.del_message_label(doc.loc, doc.get_labels())
        corpus.add_message_label(doc.loc, label_add)
      if dryrun or verbose:
        message.show_digest(self.terminal, i, False,
                            doc, self.get_selection(), label_add)
    return

  # cmd_sel
  def cmd_sel(self, args):
    'usage: sel [-q] [selection]'
    try:
      (opts, args) = getopt(args, 'q')
    except GetoptError:
      raise Kernel.ShowUsage()
    #
    verbose = 1
    for (k,v) in opts:
      if k == '-q': verbose = 0
    #
    selections = self.list_selections()