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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import sys
  5. import os
  6. USE_PEAK = False
  7. if USE_PEAK:
  8.     import peak
  9.     peak.install()
  10.  
  11.  
  12. try:
  13.     import svnrev
  14.     svnrev.REVISION
  15. except Exception:
  16.     sys.REVISION = 'dev'
  17.  
  18. sys.REVISION = svnrev.REVISION
  19. sys.TAG = ''
  20.  
  21. try:
  22.     import devmode
  23. except Exception:
  24.     sys.DEV = False
  25.  
  26. sys.DEV = devmode.awesome
  27. sepjoin = os.pathsep.join
  28. pathjoin = os.path.join
  29. lib_dir = pathjoin(os.path.dirname(sys.executable), 'lib')
  30. os.environ['PATH'] = sepjoin([
  31.     os.environ['PATH'],
  32.     lib_dir])
  33. if USE_PEAK:
  34.     
  35.     def __monkeypatch_wx__CallAfter(mod):
  36.         print 'lololmonkeypatch'
  37.         import wx
  38.         wx.CallAfter = mod.CallAfterCombining
  39.  
  40.     __monkeypatch_wx__CallAfter = peak.whenImported('events')(__monkeypatch_wx__CallAfter)
  41.  
  42. import __builtin__
  43.  
  44. class Sentinel:
  45.     
  46.     def __init__(self, *a, **k):
  47.         pass
  48.  
  49.     
  50.     def __repr__(self):
  51.         return '<Sentinel %s>' % id(self)
  52.  
  53.     
  54.     def __nonzero__(self):
  55.         return False
  56.  
  57.  
  58. __builtin__.Sentinel = Sentinel
  59. __builtin__.sentinel = Sentinel()
  60. sys.modules['psyco'] = None
  61. restricted_names = frozenset([
  62.     'password',
  63.     'secret',
  64.     'pass',
  65.     'passwd'])
  66. OMITTED = '<OMITTED>'
  67. VALUE_LENGTH_LIMIT = 360
  68.  
  69. def formatexception(excinfo = None, lastframes = 8):
  70.     import StringIO
  71.     import traceback
  72.     if excinfo is None:
  73.         excinfo = sys.exc_info()
  74.     
  75.     s = StringIO.StringIO()
  76.     tb = excinfo[2]
  77.     stack = []
  78.     if tb is not None:
  79.         while True:
  80.             if not tb.tb_next:
  81.                 break
  82.             
  83.             tb = tb.tb_next
  84.         f = tb.tb_frame
  85.         while f:
  86.             stack.append(f)
  87.             f = f.f_back
  88.     
  89.     stack.reverse()
  90.     if len(stack) > lastframes:
  91.         stack = stack[-lastframes:]
  92.     
  93.     print >>s, '\nVariables by last %d frames, innermost last' % (lastframes,)
  94.     restricted_values = []
  95.     for frame in stack:
  96.         print >>s, ''
  97.         print >>s, '  File "%s", line %d, in %s' % (frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name)
  98.         for key, value in frame.f_locals.items():
  99.             if type(value) == type(sys):
  100.                 continue
  101.             
  102.             if key == '__builtins__':
  103.                 continue
  104.             
  105.             for badthing in restricted_names:
  106.                 if badthing in key and value:
  107.                     restricted_values.append(value)
  108.                     value = OMITTED
  109.                     continue
  110.             
  111.             print >>s, '%15s = ' % (key,),
  112.             
  113.             try:
  114.                 if isinstance(value, type({ })) and value:
  115.                     valstring = []
  116.                     for _kk, _vv in sorted(value.items()):
  117.                         if _kk == '__builtins__':
  118.                             continue
  119.                         
  120.                         if (any,)((lambda .0: for x in .0:
  121. x in _kk)(restricted_names)) and _vv:
  122.                             valstring.append('%s=%r' % (_kk, OMITTED))
  123.                             restricted_values.append(_vv)
  124.                             continue
  125.                         valstring.append('%s=%r' % (_kk, _vv))
  126.                     
  127.                     valstring = ' '.join(valstring)[:VALUE_LENGTH_LIMIT]
  128.                     print >>s, valstring,
  129.                 else:
  130.                     print >>s, repr(value)[:VALUE_LENGTH_LIMIT]
  131.             continue
  132.             print >>s, '(Exception occurred printing value)'
  133.             continue
  134.  
  135.         
  136.     
  137.     traceback.print_exception(*excinfo, **{
  138.         'file': s })
  139.     retval = s.getvalue()
  140.     if isinstance(retval, unicode):
  141.         retval_str = retval.encode('utf-8', 'replace')
  142.     else:
  143.         retval_str = retval
  144.     for value in restricted_values:
  145.         if not value or value == OMITTED:
  146.             continue
  147.         
  148.         
  149.         try:
  150.             value_type = type(value)
  151.             if issubclass(value_type, basestring):
  152.                 if issubclass(value_type, unicode):
  153.                     value_str = value.encode('utf-8', 'replace')
  154.                 elif issubclass(value_type, str):
  155.                     value_str = value
  156.                 
  157.                 retval_str = retval_str.replace(value_str, OMITTED)
  158.             
  159.             retval_str = retval_str.replace(repr(value)[:VALUE_LENGTH_LIMIT], OMITTED)
  160.         continue
  161.         except UnicodeError:
  162.             continue
  163.             continue
  164.         
  165.  
  166.     
  167.     return retval
  168.  
  169. import traceback
  170. traceback._old_print_exc = traceback.print_exc
  171. traceback._old_format_exc = traceback.format_exc
  172.  
  173. def print_exc(limit = None, file = None):
  174.     
  175.     try:
  176.         if file is None:
  177.             file = sys.stderr
  178.         
  179.         formattedexc = formatexception()
  180.         file.write(formattedexc)
  181.     except:
  182.         traceback._old_print_exc()
  183.  
  184.  
  185. traceback.print_exc = print_exc
  186.  
  187. def format_exc():
  188.     
  189.     try:
  190.         return formatexception()
  191.     except:
  192.         return traceback._old_format_exc()
  193.  
  194.  
  195. traceback.format_exc = formatexception
  196. print_exc_once_cache = set()
  197. import inspect
  198.  
  199. def print_exc_once():
  200.     import traceback
  201.     
  202.     try:
  203.         frame = inspect.currentframe()
  204.         filename = frame.f_back.f_code.co_filename
  205.         line_number = frame.f_lineno
  206.         key = (filename, line_number)
  207.     except Exception:
  208.         traceback.print_exc()
  209.  
  210.     if key not in print_exc_once_cache:
  211.         traceback.print_exc()
  212.         print_exc_once_cache.add(key)
  213.     
  214.  
  215. traceback.print_exc_once = print_exc_once
  216.  
  217. def eh(*args):
  218.     
  219.     try:
  220.         print >>sys.stderr, formatexception(args)
  221.     except:
  222.         print >>sys.stderr, args
  223.  
  224.  
  225. if True:
  226.     sys.excepthook = eh
  227.  
  228. del traceback
  229.  
  230. class NullType(object):
  231.     
  232.     def __new__(cls, *args, **kwargs):
  233.         if '_inst' not in vars(cls):
  234.             cls._inst = object.__new__(cls, *args, **kwargs)
  235.         
  236.         return cls._inst
  237.  
  238.     
  239.     def __init__(self, *args, **kwargs):
  240.         pass
  241.  
  242.     
  243.     def __call__(self, *args, **kwargs):
  244.         return self
  245.  
  246.     
  247.     def __repr__(self):
  248.         return '<Null>'
  249.  
  250.     
  251.     def __nonzero__(self):
  252.         return False
  253.  
  254.     
  255.     def __getattr__(self, name):
  256.         return self
  257.  
  258.     
  259.     def __setattr__(self, name, value):
  260.         return self
  261.  
  262.     
  263.     def __delattr__(self, name):
  264.         return self
  265.  
  266.  
  267. __builtin__.Null = NullType()
  268. del NullType
  269. find_library = None
  270. if os.name == 'nt':
  271.     
  272.     def find_library(name):
  273.         for directory in sys.path + os.environ['PATH'].split(os.pathsep):
  274.             fname = os.path.join(directory, name)
  275.             if os.path.exists(fname):
  276.                 return fname
  277.             
  278.             if fname.lower().endswith('.dll'):
  279.                 continue
  280.             
  281.             fname = fname + '.dll'
  282.             if os.path.exists(fname):
  283.                 return fname
  284.                 continue
  285.         
  286.  
  287.  
  288. if find_library is not None:
  289.     import ctypes.util as ctypes
  290.     ctypes.util.find_library = find_library
  291.  
  292. del find_library
  293.