home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1367 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.6 KB  |  47 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
  6. __docformat__ = 'restructuredtext en'
  7. import time
  8. import cherrypy
  9. from calibre import strftime as _strftime, prints
  10. from calibre.utils.date import now as nowf
  11.  
  12. def expose(func):
  13.     
  14.     def do(*args, **kwargs):
  15.         self = func.im_self
  16.         if self.opts.develop:
  17.             start = time.time()
  18.         
  19.         dict.update(cherrypy.response.headers, {
  20.             'Server': self.server_name })
  21.         if not self.embedded:
  22.             self.db.check_if_modified()
  23.         
  24.         ans = func(*args, **kwargs)
  25.         if self.opts.develop:
  26.             prints('Function', func.__name__, 'called with args:', args, kwargs)
  27.             prints('\tTime:', func.__name__, time.time() - start)
  28.         
  29.         return ans
  30.  
  31.     do.__name__ = func.__name__
  32.     return do
  33.  
  34.  
  35. def strftime(fmt = '%Y/%m/%d %H:%M:%S', dt = None):
  36.     if not hasattr(dt, 'timetuple'):
  37.         dt = nowf()
  38.     
  39.     dt = dt.timetuple()
  40.     
  41.     try:
  42.         return _strftime(fmt, dt)
  43.     except:
  44.         return _strftime(fmt, nowf().timetuple())
  45.  
  46.  
  47.