summaryrefslogtreecommitdiff
path: root/xmlbrowser
diff options
context:
space:
mode:
authorDavid Wührer <def@gmx.at>2024-05-18 21:04:34 +0200
committerDavid Wührer <def@gmx.at>2024-05-18 21:04:34 +0200
commit77cfffee6177fb0421fa0fce15d6a1875bde4816 (patch)
tree251428cdd482ea50cfb019dbd3c3bafd79d2fd14 /xmlbrowser
parent75b23ce1ff0daab363725a2a5755ea80bbeaa68e (diff)
manuals, sum-down, radix
Diffstat (limited to 'xmlbrowser')
-rwxr-xr-xxmlbrowser39
1 files changed, 0 insertions, 39 deletions
diff --git a/xmlbrowser b/xmlbrowser
deleted file mode 100755
index 731b466..0000000
--- a/xmlbrowser
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/python3
-
-import sys
-import xml.etree.ElementTree as ET
-
-from qtpy import QtGui, QtWidgets, QtCore
-from qtpy.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem, QLabel
-
-def _make_item(element) -> QTreeWidgetItem:
- r = QTreeWidgetItem([element.tag, None, element.text])
- r.addChildren([QTreeWidgetItem([None, name, value]) for name, value in element.attrib.items()])
- r.addChildren([_make_item(child) for child in element])
- return r
-
-def main():
- app = QApplication(sys.argv)
- # TODO: Check for suitable arguments first.
- # Parameter may be a Qt option.
- if len(sys.argv) == 1:
- print("Usage:", sys.argv[0], "[file …]", file=sys.stderr)
- return
-
- items = []
- for arg in sys.argv[1:]:
- with open(arg) as xmlfile:
- xmltree = ET.parse(xmlfile)
- fileItem = QTreeWidgetItem([arg])
- items.append(fileItem)
- fileItem.addChildren([_make_item(xmltree.getroot())])
-
- tree = QTreeWidget()
- tree.setColumnCount(2)
- tree.setHeaderLabels(["Element", "attribute", "text"])
- tree.insertTopLevelItems(0, items)
- tree.show()
- sys.exit(app.exec_()) # Main loop.
-
-if __name__ == '__main__':
- main()