示例#1
0
 def handler (self, cmd) :
     i_enc       = cmd.input_encoding
     tfmt        = self.time_fmt = cmd.time_format
     for arg in cmd.argv :
         if arg == "-" :
             arg = "STDIN"
         output = Filename (".pdf", cmd.Output or arg).name
         if arg == "STDIN" :
             file_time   = time.localtime ()
             fn          = output
             txt_in      = sys.stdin.read ()
         else :
             file_time   = time.localtime (sos.path.getmtime (arg))
             fn          = self._display_filename (cmd, arg)
             with open (arg, "rb") as fi :
                 txt_in  = fi.read ()
         txt     = Untabified \
             (pyk.decoded    (txt_in, i_enc).lstrip ("\n\f").rstrip ())
         ft      = time.strftime  (tfmt, file_time)
         options = self._pdf_opts (cmd, arg, fn, ft, output)
         if cmd.show_options :
             from   _TFL.formatted_repr import formatted_repr
             print (formatted_repr (options))
         ofn     = options ["output"]
         pdf_doc = PDF_Doc (txt, ** options)
         if cmd.Display :
             subprocess.run ([cmd.display_program, ofn])
         elif cmd.Print :
             subprocess.run ([cmd.print_program,   ofn])
         if cmd.purge_pdf and (cmd.Display or cmd.Print) :
             sos.unlink (ofn)
         elif cmd.verbose :
             print ("Created file", ofn)
示例#2
0
 def _new2cur (self, m) :
     join = sos.path.join
     path = self.path
     s    =          join (path, "new", m.name)
     t    = m.path = join (path, "cur", m.name)
     sos.link    (s, t)
     sos.unlink  (s)
     m.email._pma_dir = "cur"
示例#3
0
文件: Mailbox.py 项目: Tapyr/tapyr
 def _new2cur (self, m) :
     join = sos.path.join
     path = self.path
     s    =          join (path, "new", m.name)
     t    = m.path = join (path, "cur", m.name)
     sos.link    (s, t)
     sos.unlink  (s)
     m.email._pma_dir = "cur"
示例#4
0
 def delete_subbox (self, subbox) :
     """Delete this subbox and all messages contained inthis subbox."""
     subbox.delete ()
     self.change_list.append (PMA.SCM.Remove_Subbox (subbox))
     self.change_count += 1
     if subbox.supports_status and sos.path.isfile (subbox.status_fn) :
         ### a newly created mailbox without closing the application has no
         ### status file
         sos.unlink (subbox.status_fn)
     del self._box_dict [subbox.name]
示例#5
0
文件: Mailbox.py 项目: Tapyr/tapyr
 def delete_subbox (self, subbox) :
     """Delete this subbox and all messages contained inthis subbox."""
     subbox.delete ()
     self.change_list.append (PMA.SCM.Remove_Subbox (subbox))
     self.change_count += 1
     if subbox.supports_status and sos.path.isfile (subbox.status_fn) :
         ### a newly created mailbox without closing the application has no
         ### status file
         sos.unlink (subbox.status_fn)
     del self._box_dict [subbox.name]
示例#6
0
 def delete (self, * messages) :
     try :
         deleted = []
         for m in messages :
             sos.unlink (m.path)
             del self._msg_dict [m.name]
             deleted.append (m)
     finally :
         self._messages = None
         self.change_list.append (PMA.SCM.Remove_Messages (* deleted))
         self.change_count += len (messages)
示例#7
0
文件: Manager.py 项目: JPilarr/tapyr
 def delete_database(cls, db_url):
     uri = db_url.path
     try:
         sos.unlink(uri)
     except OSError:
         pass
     x_uri = MOM.DBW.HPS.Store.X_Uri(uri).name
     try:
         sos.rmdir(x_uri, True)
     except OSError:
         pass
示例#8
0
文件: Mailbox.py 项目: Tapyr/tapyr
 def delete (self, * messages) :
     try :
         deleted = []
         for m in messages :
             sos.unlink (m.path)
             del self._msg_dict [m.name]
             deleted.append (m)
     finally :
         self._messages = None
         self.change_list.append (PMA.SCM.Remove_Messages (* deleted))
         self.change_count += len (messages)
示例#9
0
文件: Manager.py 项目: Tapyr/tapyr
 def delete_database (cls, db_url) :
     uri = db_url.path
     try :
         sos.unlink (uri)
     except OSError :
         pass
     x_uri = MOM.DBW.HPS.Store.X_Uri (uri).name
     try :
         sos.rmdir (x_uri, True)
     except OSError :
         pass
示例#10
0
 def download_pop (self, server, mdir) :
     md_name = PMA._Mailbox_.md_name
     result  = 0
     for msg_no, msg_size in self.pop_list (server) :
         email = self._new_email ("\n".join (server.retr (msg_no) [1]))
         name  = md_name         ()
         tname = sos.path.join   (mdir.path, "tmp", name)
         nname = sos.path.join   (mdir.path, "new", name)
         PMA.save    (tname, email.as_string ())
         sos.link    (tname, nname)
         sos.unlink  (tname)
         server.dele (msg_no)
         result += 1
         if self.finish :
             break
     return result
示例#11
0
 def delete_database(cls, db_url, manager):
     try:
         sos.unlink(db_url.path)
     except OSError:
         pass
示例#12
0
 def delete_file(self, name):
     full_name = sos.path.join(self.name, name)
     if self.last_file and self.last_file.name == full_name:
         self.closefile()
     self._remove_file(name)
     sos.unlink(full_name)
示例#13
0
 def _clear_dir (self) :
     for fod in sos.listdir_full (self.media_dir) :
         if sos.path.isdir (fod) :
             sos.rmdir  (fod, True)
         else :
             sos.unlink (fod)
示例#14
0
 def _clear_dir (self) :
     for fod in sos.listdir_full (self.media_dir) :
         if sos.path.isdir (fod) :
             sos.rmdir  (fod, True)
         else :
             sos.unlink (fod)
示例#15
0
文件: Sync_File.py 项目: Tapyr/tapyr
 def delete_file (self, name) :
     full_name = sos.path.join (self.name, name)
     if self.last_file and self.last_file.name == full_name :
         self.closefile ()
     self._remove_file  (name)
     sos.unlink         (full_name)
示例#16
0
文件: _DBS_.py 项目: Tapyr/tapyr
 def delete_database (cls, db_url, manager) :
     try :
         sos.unlink (db_url.path)
     except OSError :
         pass