Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dump.py 1.8KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import traceback
  2. import pythoncom
  3. from win32com.axdebug import axdebug
  4. from win32com.client.util import Enumerator
  5. def DumpDebugApplicationNode(node, level=0):
  6. # Recursive dump of a DebugApplicationNode
  7. spacer = " " * level
  8. for desc, attr in [
  9. ("Node Name", axdebug.DOCUMENTNAMETYPE_APPNODE),
  10. ("Title", axdebug.DOCUMENTNAMETYPE_TITLE),
  11. ("Filename", axdebug.DOCUMENTNAMETYPE_FILE_TAIL),
  12. ("URL", axdebug.DOCUMENTNAMETYPE_URL),
  13. ]:
  14. try:
  15. info = node.GetName(attr)
  16. except pythoncom.com_error:
  17. info = "<N/A>"
  18. print("%s%s: %s" % (spacer, desc, info))
  19. try:
  20. doc = node.GetDocument()
  21. except pythoncom.com_error:
  22. doc = None
  23. if doc:
  24. doctext = doc.QueryInterface(axdebug.IID_IDebugDocumentText)
  25. numLines, numChars = doctext.GetSize()
  26. # text, attr = doctext.GetText(0, 20, 1)
  27. text, attr = doctext.GetText(0, numChars, 1)
  28. print(
  29. "%sText is %s, %d bytes long" % (spacer, repr(text[:40] + "..."), len(text))
  30. )
  31. else:
  32. print("%s%s" % (spacer, "<No document available>"))
  33. for child in Enumerator(node.EnumChildren()):
  34. DumpDebugApplicationNode(child, level + 1)
  35. def dumpall():
  36. dm = pythoncom.CoCreateInstance(
  37. axdebug.CLSID_MachineDebugManager,
  38. None,
  39. pythoncom.CLSCTX_ALL,
  40. axdebug.IID_IMachineDebugManager,
  41. )
  42. e = Enumerator(dm.EnumApplications())
  43. for app in e:
  44. print("Application: %s" % app.GetName())
  45. node = (
  46. app.GetRootNode()
  47. ) # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo
  48. DumpDebugApplicationNode(node)
  49. if __name__ == "__main__":
  50. try:
  51. dumpall()
  52. except:
  53. traceback.print_exc()