home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / plugin_manager / plugin_hub.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  2.8 KB  |  57 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from peak.util.plugins import Hook
  5. from util.threads import threaded
  6. from logging import getLogger
  7. _log = log = getLogger('plugin_hub')
  8. import traceback
  9.  
  10. def asyn(identifier, *args, **kwargs):
  11.     threaded(syn)(identifier, *args, **kwargs)
  12.  
  13.  
  14. def syn(identifier, *args, **kwargs):
  15.     ret = True
  16.     for hook in Hook(identifier):
  17.         
  18.         try:
  19.             ret = hook(*args, **kwargs)
  20.             if not ret:
  21.                 ret = False
  22.         continue
  23.         except Exception:
  24.             traceback.print_exc()
  25.             continue
  26.         
  27.  
  28.     
  29.     return ret
  30.  
  31.  
  32. def act(id, *args, **kwargs):
  33.     if id.endswith('.async'):
  34.         asyn(id, *args, **kwargs)
  35.     else:
  36.         ret = syn(id, *args, **kwargs)
  37.         return ret
  38.  
  39. hooks = '\nim:\n  filetransfer: syn, buddy, file, state\n  alert:\n    pre: syn, proto, type, param\n  msg:\n    pre: syn, message, type\n    async: syn, msg, type\n  my_status_change:\n    pre: syn, msg\n    async: syn, msg\n  setprofile:\n    pre: syn, proto, profile\n    async: syn, proto, profile\n  status_change:\n    pre: syn, proto, buddy\n    async: syn, proto, buddy\n  info:\n    pre: syn, proto, buddy, info\n    async: syn, proto, buddy, info\n  conversation:\n    start:\n      pre: syn, proto, buddy\n      async: syn, proto, buddy\n    end:\n      async: syn, proto, buddy\n  addcontact:\n    pre: syn, proto, name, alias\n    async: syn, proto, name, alias\n  addaccount:\n    async: syn, proto_name, acct_name\nupdateaccount:\n  async: syn, account\nsocial:\n  addaccount:\n    async: syn, proto_name, acct_name\n  alert: syn, proto, type, msg\nprotocol:\n  statechange:\n    async: syn, state\nplugin:\n  load:\n    async: syn\n  unload:\n    async: syn\ngoidle:\n  pre: syn\n  async: syn\nunidle:\n  pre: syn\n  async: syn\nemail:\n  newmail:\n    pre: syn, proto, address, count, msg\n    async: syn, proto, address, count, msg\n  addaccount:\n    async: syn, proto_name, acct_name\n'
  40. functemp = "def %(func_name)s(%(def_args)s):\n    return %(type)s('%(func_id)s'%(func_args)s)\n"
  41. from prefs import flatten
  42. from syck import load
  43. funcs = flatten(load(hooks))
  44. for func_id, args in funcs:
  45.     func_id = 'digsby.' + func_id
  46.     args = args.split(', ')
  47.     type = args[0]
  48.     func_args = args[1:]
  49.     def_args = ', '.join(func_args)
  50.     if func_args:
  51.         func_args = ', ' + def_args
  52.     else:
  53.         func_args = ''
  54.     func_name = func_id.replace('.', '_')
  55.     exec (functemp % locals(), globals(), locals())
  56.  
  57.