]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/util/__init__.py
fixed assert when dumping a string which is locked for writing
[wxWidgets.git] / wxPython / samples / ide / activegrid / util / __init__.py
index b5380e6b13e8ed0f047994d48eb028705e1f627b..943607976fb1a401a2da1d7d0c737edc4c0e6436 100644 (file)
 # License:      wxWindows License
 #----------------------------------------------------------------------------
 
-import logging
-import cStringIO
 import traceback
 import sys
-import string
 import os
 
-def classForName(className):
-    pathList = className.split('.')
-    moduleName = string.join(pathList[:-1], '.')
-    code = __import__(moduleName)
-    for name in pathList[1:]:
-        code = code.__dict__[name]
-    return code
-
-def hasattrignorecase(object, name):
-    for attr in dir(object):
-        if attr.lower() == name.lower():
-            return True
-    for attr in dir(object):
-        if attr.lower() == '_' + name.lower():
-            return True
-    return False
-
-
-def setattrignorecase(object, name, value):
-    for attr in object.__dict__:
-        if attr.lower() == name.lower():
-            object.__dict__[attr] = value
-            return
-##    for attr in dir(object):
-##        if attr.lower() == '_' + name.lower():
-##            object.__dict__[attr] = value
-##            return
-    object.__dict__[name] = value
-    
-def getattrignorecase(object, name):
-    for attr in object.__dict__:
-        if attr.lower() == name.lower():
-            return object.__dict__[attr]
-##    for attr in dir(object):
-##        if attr.lower() == '_' + name.lower():
-##            return object.__dict__[attr]
-    return object.__dict__[name]
-
-
-def defaultLoad(fileObject, knownTypes=None):
-    xml = fileObject.read()
-    loadedObject = xmlmarshaller.unmarshal(xml, knownTypes=knownTypes)
-    if hasattr(fileObject, 'name'):
-        loadedObject.fileName = os.path.abspath(fileObject.name)
-    loadedObject.initialize()
-    return loadedObject
-
-def defaultSave(fileObject, objectToSave, knownTypes=None):
-    xml = xmlmarshaller.marshal(objectToSave, prettyPrint=True, knownTypes=knownTypes)
-    fileObject.write(xml)
-    fileObject.close()
-def clone(objectToClone):
-    xml = xmlmarshaller.marshal(objectToClone, prettyPrint=True)
-    clonedObject = xmlmarshaller.unmarshal(xml)
-    if hasattr(objectToClone, 'fileName'):
-        clonedObject.fileName = objectToClone.fileName
-    clonedObject.initialize()
-    return clonedObject
-    
-def exceptionToString(e):
-    sio = cStringIO.StringIO()
-    traceback.print_exception(e.__class__, e, sys.exc_traceback, file=sio)
-    return sio.getvalue()
+def isWindows():
+    return os.name == 'nt'
+
+def _generateMainModuleDir():
+    if sys.executable.find('python') != -1:
+        utilModuleDir = os.path.dirname(__file__)
+        if not os.path.isabs(utilModuleDir):
+            utilModuleDir = os.path.join(os.getcwd(), utilModuleDir)
+        mainModuleDir = os.path.normpath(os.path.join(utilModuleDir, os.path.join(os.path.pardir, os.path.pardir)))
+        if mainModuleDir.endswith('.zip'):
+            mainModuleDir = os.path.dirname(mainModuleDir) # Get rid of library.zip
+    else:
+        mainModuleDir = os.path.dirname(sys.executable)
+    return mainModuleDir
+
+mainModuleDir = _generateMainModuleDir()
+
+
+def _generatePythonExecPath():
+    if sys.executable.find('python') != -1:
+        pythonExecPath = sys.executable
+    else:
+        pythonExecPath = os.path.join(os.path.dirname(sys.executable), '3rdparty\python2.3\python')
+    return pythonExecPath
+
+pythonExecPath = _generatePythonExecPath()
+
+def getCommandNameForExecPath(execPath):
+    if isWindows():
+        return '"%s"' % execPath
+    return execPath