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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4.  
  5. class IPythonGrowlError(Exception):
  6.     pass
  7.  
  8.  
  9. class Notifier(object):
  10.     
  11.     def __init__(self, app_name):
  12.         
  13.         try:
  14.             import Growl
  15.         except ImportError:
  16.             self.g_notifier = None
  17.  
  18.         self.g_notifier = Growl.GrowlNotifier(app_name, [
  19.             'kernel',
  20.             'core'])
  21.         self.g_notifier.register()
  22.  
  23.     
  24.     def _notify(self, title, msg):
  25.         if self.g_notifier is not None:
  26.             self.g_notifier.notify('kernel', title, msg)
  27.         
  28.  
  29.     
  30.     def notify(self, title, msg):
  31.         self._notify(title, msg)
  32.  
  33.     
  34.     def notify_deferred(self, r, msg):
  35.         title = 'Deferred Result'
  36.         msg = msg + '\n' + repr(r)
  37.         self._notify(title, msg)
  38.         return r
  39.  
  40.  
  41. _notifier = None
  42.  
  43. def notify(title, msg):
  44.     pass
  45.  
  46.  
  47. def notify_deferred(r, msg):
  48.     return r
  49.  
  50.  
  51. def start(app_name):
  52.     global _notifier, notify, notify_deferred
  53.     if _notifier is not None:
  54.         raise IPythonGrowlError('this process is already registered with Growl')
  55.     _notifier is not None
  56.     _notifier = Notifier(app_name)
  57.     notify = _notifier.notify
  58.     notify_deferred = _notifier.notify_deferred
  59.  
  60.