home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / digsbysite.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  9.1 KB  |  369 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import sys
  5. import os
  6. import bootstrap
  7. if os.name == 'nt':
  8.     import ctypes
  9.     ctypes.OleDLL._func_restype_ = ctypes.c_void_p
  10.  
  11. USE_PEAK = False
  12. if USE_PEAK:
  13.     import peak
  14.     peak.install()
  15.  
  16.  
  17. try:
  18.     import svnrev
  19.     svnrev.REVISION
  20. except Exception:
  21.     sys.REVISION = 'dev'
  22.  
  23. sys.REVISION = svnrev.REVISION
  24. sys.TAG = ''
  25.  
  26. try:
  27.     import devmode
  28. except Exception:
  29.     sys.DEV = False
  30.  
  31. sys.DEV = devmode.awesome
  32. sys.BRAND = None
  33. sepjoin = os.pathsep.join
  34. pathjoin = os.path.join
  35. lib_dir = pathjoin(os.path.dirname(sys.executable), 'lib')
  36. os.environ['PATH'] = sepjoin([
  37.     os.environ['PATH'],
  38.     lib_dir])
  39. if USE_PEAK:
  40.     
  41.     def __monkeypatch_wx__CallAfter(mod):
  42.         print 'lololmonkeypatch'
  43.         import wx
  44.         wx.CallAfter = mod.CallAfterCombining
  45.  
  46.     __monkeypatch_wx__CallAfter = peak.whenImported('events')(__monkeypatch_wx__CallAfter)
  47.  
  48. bootstrap.install_sentinel()
  49. sys.modules['psyco'] = None
  50. restricted_names = frozenset([
  51.     'password',
  52.     'secret',
  53.     'pass',
  54.     'passwd'])
  55. OMITTED = '<OMITTED>'
  56. VALUE_LENGTH_LIMIT = 360
  57.  
  58. def formatexception(excinfo = None, lastframes = 8):
  59.     import StringIO
  60.     import traceback
  61.     if excinfo is None:
  62.         excinfo = sys.exc_info()
  63.     
  64.     s = StringIO.StringIO()
  65.     tb = excinfo[2]
  66.     stack = []
  67.     if tb is not None:
  68.         while True:
  69.             if not tb.tb_next:
  70.                 break
  71.             
  72.             tb = tb.tb_next
  73.         f = tb.tb_frame
  74.         while f:
  75.             stack.append(f)
  76.             f = f.f_back
  77.     
  78.     stack.reverse()
  79.     if len(stack) > lastframes:
  80.         stack = stack[-lastframes:]
  81.     
  82.     print >>s, '\nVariables by last %d frames, innermost last' % (lastframes,)
  83.     restricted_values = []
  84.     for frame in stack:
  85.         print >>s, ''
  86.         print >>s, '  File "%s", line %d, in %s' % (frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name)
  87.         for key, value in frame.f_locals.items():
  88.             if type(value) == type(sys):
  89.                 continue
  90.             
  91.             if key == '__builtins__':
  92.                 continue
  93.             
  94.             for badthing in restricted_names:
  95.                 if badthing in key and value:
  96.                     restricted_values.append(value)
  97.                     value = OMITTED
  98.                     continue
  99.             
  100.             print >>s, '%15s = ' % (key,),
  101.             
  102.             try:
  103.                 if isinstance(value, type({ })) and value:
  104.                     valstring = []
  105.                     for _kk, _vv in sorted(value.items()):
  106.                         if _kk == '__builtins__':
  107.                             continue
  108.                         
  109.                         if (any,)((lambda .0: for x in .0:
  110. x in _kk)(restricted_names)) and _vv:
  111.                             valstring.append('%s=%r' % (_kk, OMITTED))
  112.                             restricted_values.append(_vv)
  113.                             continue
  114.                         valstring.append('%s=%r' % (_kk, _vv))
  115.                     
  116.                     valstring = ' '.join(valstring)[:VALUE_LENGTH_LIMIT]
  117.                     print >>s, valstring,
  118.                 else:
  119.                     print >>s, repr(value)[:VALUE_LENGTH_LIMIT]
  120.             continue
  121.             print >>s, '(Exception occurred printing value)'
  122.             continue
  123.  
  124.         
  125.     
  126.     traceback.print_exception(*excinfo, **{
  127.         'file': s })
  128.     retval = s.getvalue()
  129.     if isinstance(retval, unicode):
  130.         retval_str = retval.encode('utf-8', 'replace')
  131.     else:
  132.         retval_str = retval
  133.     for value in restricted_values:
  134.         if not value or value == OMITTED:
  135.             continue
  136.         
  137.         
  138.         try:
  139.             value_type = type(value)
  140.             if issubclass(value_type, basestring):
  141.                 if issubclass(value_type, unicode):
  142.                     value_str = value.encode('utf-8', 'replace')
  143.                 elif issubclass(value_type, str):
  144.                     value_str = value
  145.                 
  146.                 retval_str = retval_str.replace(value_str, OMITTED)
  147.             
  148.             retval_str = retval_str.replace(repr(value)[:VALUE_LENGTH_LIMIT], OMITTED)
  149.         continue
  150.         except UnicodeError:
  151.             continue
  152.             continue
  153.         
  154.  
  155.     
  156.     return retval
  157.  
  158. import traceback
  159. traceback._old_print_exc = traceback.print_exc
  160. traceback._old_format_exc = traceback.format_exc
  161. COLORIZE_EXCEPTIONS = False
  162. SHOW_TRACEBACK_DIALOG = sys.DEV
  163.  
  164. def get_exc_dialog():
  165.     diag = getattr(sys, 'exc_dialog', None)
  166.     if diag is not None:
  167.         import wx
  168.         if wx.IsDestroyed(diag):
  169.             diag = None
  170.         
  171.     
  172.     if diag is None:
  173.         import gui.tracebackdialog as gui
  174.         diag = sys.exc_dialog = gui.tracebackdialog.ErrorDialog()
  175.     
  176.     return diag
  177.  
  178.  
  179. def tb_pref_enabled():
  180.     import common
  181.     return common.pref('debug.traceback_dialog', default = True)
  182.  
  183.  
  184. def print_exc(limit = None, file = None):
  185.     traceback.format_exc = traceback._old_format_exc()
  186.     
  187.     try:
  188.         if file is None:
  189.             file = sys.stderr
  190.         
  191.         formattedexc = formatexception()
  192.         if SHOW_TRACEBACK_DIALOG and tb_pref_enabled():
  193.             
  194.             def show_dialog():
  195.                 
  196.                 try:
  197.                     diag = get_exc_dialog()
  198.                     diag.AppendText(formattedexc + '\n\n')
  199.                     if not diag.IsShown():
  200.                         diag.CenterOnScreen()
  201.                     
  202.                     diag.Show()
  203.                 except Exception:
  204.                     print sys.stderr, 'error showing exception dialog: %r' % e
  205.  
  206.  
  207.             import wx
  208.             if wx.App.IsMainLoopRunning():
  209.                 wx.CallAfter(show_dialog)
  210.             
  211.         
  212.         if COLORIZE_EXCEPTIONS and file is sys.stderr:
  213.             console = console
  214.             import gui.native.win
  215.             console.color('bold red').__enter__()
  216.             
  217.             try:
  218.                 file.write(formattedexc)
  219.             finally:
  220.                 pass
  221.  
  222.         else:
  223.             file.write(formattedexc)
  224.     except:
  225.         traceback._old_print_exc()
  226.     finally:
  227.         traceback.format_exc = formatexception
  228.  
  229.  
  230. traceback.print_exc = print_exc
  231.  
  232. def format_exc():
  233.     traceback.format_exc = traceback._old_print_exc()
  234.     
  235.     try:
  236.         return formatexception()
  237.     except:
  238.         return traceback._old_format_exc()
  239.     finally:
  240.         traceback.format_exc = formatexception
  241.  
  242.  
  243. traceback.format_exc = formatexception
  244. print_exc_once_cache = set()
  245. import inspect
  246.  
  247. def print_exc_once():
  248.     import traceback
  249.     
  250.     try:
  251.         frame = inspect.currentframe()
  252.         filename = frame.f_back.f_code.co_filename
  253.         line_number = frame.f_lineno
  254.         key = (filename, line_number)
  255.     except Exception:
  256.         traceback.print_exc()
  257.  
  258.     if key not in print_exc_once_cache:
  259.         traceback.print_exc()
  260.         print_exc_once_cache.add(key)
  261.     
  262.  
  263. traceback.print_exc_once = print_exc_once
  264. if not sys.DEV and getattr(getattr(sys, 'opts', None), 'track_windowids', False):
  265.     pass
  266. TRACK_WINDOW_ID_ALLOCATIONS = getattr(sys, 'TAG', None) == 'alpha'
  267. if TRACK_WINDOW_ID_ALLOCATIONS:
  268.     import wx
  269.     count_map = { }
  270.     _original_NewId = wx.NewId
  271.     
  272.     def debug_NewId():
  273.         global count_map
  274.         
  275.         try:
  276.             loc = tuple(traceback.extract_stack()[-3:-1])
  277.             new_count = count_map.get(loc, 0) + 1
  278.             count_map[loc] = new_count
  279.             if len(count_map) > 100:
  280.                 count_map = dict(sorted(count_map.iteritems(), key = (lambda item: item[1]), reverse = True)[:50])
  281.         except Exception:
  282.             print_exc()
  283.  
  284.         return _original_NewId()
  285.  
  286.     wx.NewId = debug_NewId
  287.     
  288.     def get_window_id_allocs():
  289.         return count_map
  290.  
  291.  
  292.  
  293. def eh(*args):
  294.     
  295.     try:
  296.         print >>sys.stderr, formatexception(args)
  297.     except:
  298.         print >>sys.stderr, args
  299.  
  300.  
  301. if True:
  302.     sys.excepthook = eh
  303.  
  304.  
  305. class NullType(object):
  306.     
  307.     def __new__(cls, *args, **kwargs):
  308.         if '_inst' not in vars(cls):
  309.             cls._inst = object.__new__(cls, *args, **kwargs)
  310.         
  311.         return cls._inst
  312.  
  313.     
  314.     def __init__(self, *args, **kwargs):
  315.         pass
  316.  
  317.     
  318.     def __call__(self, *args, **kwargs):
  319.         return self
  320.  
  321.     
  322.     def __repr__(self):
  323.         return '<Null>'
  324.  
  325.     
  326.     def __nonzero__(self):
  327.         return False
  328.  
  329.     
  330.     def __getattr__(self, name):
  331.         return self
  332.  
  333.     
  334.     def __setattr__(self, name, value):
  335.         return self
  336.  
  337.     
  338.     def __delattr__(self, name):
  339.         return self
  340.  
  341.  
  342. import __builtin__
  343. __builtin__.Null = NullType()
  344. del NullType
  345. find_library = None
  346. if os.name == 'nt':
  347.     
  348.     def find_library(name):
  349.         for directory in sys.path + os.environ['PATH'].split(os.pathsep):
  350.             fname = os.path.join(directory, name)
  351.             if os.path.exists(fname):
  352.                 return fname
  353.             if fname.lower().endswith('.dll'):
  354.                 continue
  355.             
  356.             fname = fname + '.dll'
  357.             if os.path.exists(fname):
  358.                 return fname
  359.         
  360.  
  361.  
  362. if find_library is not None:
  363.     import ctypes.util as ctypes
  364.     ctypes.util.find_library = find_library
  365.  
  366. del find_library
  367. import gettext
  368. gettext.install('Digsby', './locale', unicode = True)
  369.