diff --git a/source/logHandler.py b/source/logHandler.py index 2f6c7e6d60c..f397fd516da 100755 --- a/source/logHandler.py +++ b/source/logHandler.py @@ -24,36 +24,6 @@ RPC_E_CALL_REJECTED = -2147418111 RPC_E_DISCONNECTED = -2147417848 -moduleCache={} - -def makeModulePathFromFilePath(path): - """calculates the pythonic dotted module path from a file path of a python module. - @param path: the relative or absolute path to the module - @type path: string - @returns: the Pythonic dotted module path - @rtype: string - """ - if path in moduleCache: - return moduleCache[path] - modPathList = [] - # Work through the path components from right to left. - curPath = path - while curPath: - curPath, curPathCom = os.path.split(curPath) - if not curPathCom: - break - curPathCom = os.path.splitext(curPathCom)[0] - # __init__ is the root module of a package, so skip it. - if curPathCom != "__init__": - modPathList.insert(0, curPathCom) - if curPath in sys.path: - # curPath is in the Python search path, so the Pythonic module path is relative to curPath. - break - modulePath = ".".join(modPathList) - if modulePath: - moduleCache[path] = modulePath - return modulePath - def getCodePath(f): """Using a frame object, gets its module path (relative to the current directory).[className.[funcName]] @param f: the frame object to use @@ -61,7 +31,15 @@ def getCodePath(f): @returns: the dotted module.class.attribute path @rtype: string """ - path=makeModulePathFromFilePath(os.path.relpath(f.f_code.co_filename)) + fn=f.f_code.co_filename + if fn[0] != "<" and (not fn.startswith(sys.path[0] + "\\") or fn.startswith(globalVars.appArgs.configPath + "\\")): + path="external:" + else: + path="" + try: + path+=f.f_globals["__name__"] + except KeyError: + path+=fn funcName=f.f_code.co_name if funcName.startswith('<'): funcName=""