X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73ed39b580977913998bbb988e52e474fe9835ae..bbf7159c8211a398e573122c66b93722f5125c60:/wxPython/samples/ide/activegrid/util/aglogging.py?ds=inline diff --git a/wxPython/samples/ide/activegrid/util/aglogging.py b/wxPython/samples/ide/activegrid/util/aglogging.py deleted file mode 100644 index 880ff822f2..0000000000 --- a/wxPython/samples/ide/activegrid/util/aglogging.py +++ /dev/null @@ -1,84 +0,0 @@ -#---------------------------------------------------------------------------- -# Name: aglogging.py -# Purpose: Utilities to help with logging -# -# Author: Jeff Norton -# -# Created: 01/04/05 -# CVS-ID: $Id$ -# Copyright: (c) 2005 ActiveGrid, Inc. -# License: wxWindows License -#---------------------------------------------------------------------------- - -import sys -import os -import re -import traceback - -global agTestMode -agTestMode = False - -def setTestMode(mode): - global agTestMode - if (mode): - agTestMode = True - else: - agTestMode = False - -def getTestMode(): - global agTestMode - return agTestMode - -def testMode(normalObj, testObj=None): - if getTestMode(): - return testObj - return normalObj - -def toDiffableString(value): - s = repr(value) - ds = "" - i = s.find(" at 0x") - start = 0 - while (i >= 0): - j = s.find(">", i) - if (j < i): - break - ds += s[start:i] - start = j - i = s.find(" at 0x", start) - return ds + s[start:] - -def removeFileRefs(str): - str = re.sub(r'(?<=File ")[^"]*(\\[^\\]*")(, line )[0-9]*', _fileNameReplacement, str) - return str - -def _fileNameReplacement(match): - return "...%s" % match.group(1) - -def getTraceback(): - extype, val, tb = sys.exc_info() - tbs = "\n" - for s in traceback.format_tb(tb): - tbs += s - return tbs - -def reportException(out=None, stacktrace=False, diffable=False): - extype, val, t = sys.exc_info() - if (diffable): - exstr = removeFileRefs(str(val)) - else: - exstr = str(val) - if (out == None): - print "Got Exception = %s: %s" % (extype, exstr) - else: - print >> out, "Got Exception = %s: %s" % (extype, exstr) - if (stacktrace): - fmt = traceback.format_exception(extype, val, t) - for s in fmt: - if (diffable): - s = removeFileRefs(s) - if (out == None): - print s - else: - print >> out, s -