summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-01 16:57:08 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-02-01 17:12:50 +0100
commitf4faef33537d96307a198e09ccf1511cf74c7b62 (patch)
treea5d313215d3328baf194e9956b32dd8e20df2741
parente73d6479e0431539cd5722d85bab457f2e684907 (diff)
pptx: add script that makes smartart uuids more readable
-rwxr-xr-xpptx-kill-uuid.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/pptx-kill-uuid.py b/pptx-kill-uuid.py
new file mode 100755
index 0000000..c930ece
--- /dev/null
+++ b/pptx-kill-uuid.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# PowerPoint generates SmartArt streams, like ppt/diagrams/data1.xml containing
+# UUIDs for each <dgm:pt> element. This makes it hard to reason about them,
+# referring to numerical identifiers is just easier in notes. This script
+# replaces UUIDs with integers, which is the style used in the OOXML spec as
+# well.
+
+import re
+import sys
+
+
+def main():
+ buf = sys.stdin.read()
+
+ counter = 0
+ while True:
+ match = re.search("\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}", buf)
+ if not match:
+ break
+ uuid = match.group()
+ buf = buf.replace(uuid, str(counter))
+ counter += 1
+
+ sys.stdout.write(buf)
+
+
+if __name__ == "__main__":
+ main()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: