]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/util/__init__.py
905f93a0ab8a692a5c0d0acb4bfb75a7f45abb77
8 def classForName(className
):
9 pathList
= className
.split('.')
10 moduleName
= string
.join(pathList
[:-1], '.')
11 code
= __import__(moduleName
)
12 for name
in pathList
[1:]:
13 code
= code
.__dict
__[name
]
16 def hasattrignorecase(object, name
):
17 for attr
in dir(object):
18 if attr
.lower() == name
.lower():
20 for attr
in dir(object):
21 if attr
.lower() == '_' + name
.lower():
26 def setattrignorecase(object, name
, value
):
27 for attr
in object.__dict
__:
28 if attr
.lower() == name
.lower():
29 object.__dict
__[attr
] = value
31 ## for attr in dir(object):
32 ## if attr.lower() == '_' + name.lower():
33 ## object.__dict__[attr] = value
35 object.__dict
__[name
] = value
37 def getattrignorecase(object, name
):
38 for attr
in object.__dict
__:
39 if attr
.lower() == name
.lower():
40 return object.__dict
__[attr
]
41 ## for attr in dir(object):
42 ## if attr.lower() == '_' + name.lower():
43 ## return object.__dict__[attr]
44 return object.__dict
__[name
]
47 def defaultLoad(fileObject
):
48 xml
= fileObject
.read()
49 loadedObject
= xmlmarshaller
.unmarshal(xml
)
50 if hasattr(fileObject
, 'name'):
51 loadedObject
.fileName
= os
.path
.abspath(fileObject
.name
)
52 loadedObject
.initialize()
55 def defaultSave(fileObject
, objectToSave
):
56 xml
= xmlmarshaller
.marshal(objectToSave
, prettyPrint
=True)
60 def clone(objectToClone
):
61 xml
= xmlmarshaller
.marshal(objectToClone
, prettyPrint
=True)
62 clonedObject
= xmlmarshaller
.unmarshal(xml
)
63 if hasattr(objectToClone
, 'fileName'):
64 clonedObject
.fileName
= objectToClone
.fileName
65 clonedObject
.initialize()
68 def exceptionToString(e
):
69 sio
= cStringIO
.StringIO()
70 traceback
.print_exception(e
.__class
__, e
, sys
.exc_traceback
, file=sio
)