|
|
@@ -6,6 +6,7 @@ import json
|
|
|
import secrets
|
|
|
import xml.etree.ElementTree as ET
|
|
|
import copy
|
|
|
+import zlib
|
|
|
|
|
|
from drawio2py.abstract_syntax import *
|
|
|
from drawio2py.parser import Parser
|
|
|
@@ -19,7 +20,10 @@ def parse_library(path) -> Dict[str, Cell]:
|
|
|
library = {}
|
|
|
for el in elements:
|
|
|
# Every element in the array has a "title" (shown to the user when hovering the shape) and "xml", which is actually Base64-encoded compressed URL-encoded XML (lol) (of an <mxgraphmodel>), which is the same format as what we encounter in a .drawio file:
|
|
|
- mxgm = Parser.decode_and_deflate(el["xml"])
|
|
|
+ try:
|
|
|
+ mxgm = Parser.decode_and_deflate(el["xml"])
|
|
|
+ except zlib.error:
|
|
|
+ mxgm = ET.fromstring(el["xml"])
|
|
|
# We create a dictionary mapping title to <mxgraphmodel>:
|
|
|
shape_root = Parser.parse_mxgraphmodel(mxgm)
|
|
|
|