home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / gui / app / __init__.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  1.7 KB  |  65 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import sip
  5. import sys
  6. import traceback
  7. import types
  8. import wx
  9.  
  10. def checkMainThread(func):
  11.     
  12.     def new(*args, **kwargs):
  13.         if not wx.IsMainThread():
  14.             import util.introspect as util
  15.             print >>sys.stderr, util.introspect.print_stack_trace()
  16.         
  17.         return func(*args, **kwargs)
  18.  
  19.     return new
  20.  
  21. excludes = [
  22.     'Event',
  23.     'Timer',
  24.     'CallLater',
  25.     'sip',
  26.     'ExitMainLoop']
  27.  
  28. def addThreadChecksToClassRecursive(obj):
  29.     for symbol in dir(obj):
  30.         objname = getattr(obj, '__name__', None)
  31.         if objname is None:
  32.             continue
  33.         
  34.         if hasattr(obj, '__module__'):
  35.             objname = obj.__module__ + '.' + objname
  36.         
  37.         if symbol.startswith('_') or objname.startswith('_'):
  38.             continue
  39.         
  40.         exclude = False
  41.         for exc in excludes:
  42.             if symbol.find(exc) != -1 or objname.find(exc) != -1:
  43.                 exclude = True
  44.                 continue
  45.         
  46.         if exclude:
  47.             continue
  48.         
  49.         
  50.         try:
  51.             sym = getattr(obj, symbol)
  52.         except:
  53.             continue
  54.  
  55.         if type(sym) == types.MethodType:
  56.             if not sym.im_self:
  57.                 exec '%s.%s = checkMainThread(%s.%s)' % (objname, symbol, objname, symbol)
  58.             
  59.         sym.im_self
  60.         if type(sym) == types.ClassType and type(sym) == types.TypeType or type(sym) == sip.wrappertype:
  61.             addThreadChecksToClassRecursive(sym)
  62.             continue
  63.     
  64.  
  65.