Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -83,12 +83,12 @@ def get_table_download_link(file_path):
|
|
83 |
href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
|
84 |
return href
|
85 |
|
86 |
-
def CompressXML(xml_text
|
87 |
root = ET.fromstring(xml_text)
|
88 |
for elem in list(root.iter()):
|
89 |
if isinstance(elem.tag, str) and 'Comment' in elem.tag:
|
90 |
elem.parent.remove(elem)
|
91 |
-
return ET.tostring(root, encoding='unicode', method="xml")
|
92 |
|
93 |
def read_file_content(file,max_length):
|
94 |
if file.type == "application/json":
|
@@ -100,8 +100,8 @@ def read_file_content(file,max_length):
|
|
100 |
elif file.type == "application/xml" or file.type == "text/xml":
|
101 |
tree = ET.parse(file)
|
102 |
root = tree.getroot()
|
103 |
-
|
104 |
-
return
|
105 |
elif file.type == "text/markdown" or file.type == "text/md":
|
106 |
md = mistune.create_markdown()
|
107 |
content = md(file.read().decode())
|
|
|
83 |
href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
|
84 |
return href
|
85 |
|
86 |
+
def CompressXML(xml_text):
|
87 |
root = ET.fromstring(xml_text)
|
88 |
for elem in list(root.iter()):
|
89 |
if isinstance(elem.tag, str) and 'Comment' in elem.tag:
|
90 |
elem.parent.remove(elem)
|
91 |
+
return ET.tostring(root, encoding='unicode', method="xml")
|
92 |
|
93 |
def read_file_content(file,max_length):
|
94 |
if file.type == "application/json":
|
|
|
100 |
elif file.type == "application/xml" or file.type == "text/xml":
|
101 |
tree = ET.parse(file)
|
102 |
root = tree.getroot()
|
103 |
+
xml = CompressXML(ET.tostring(root, encoding='unicode')
|
104 |
+
return xml(:max_length)
|
105 |
elif file.type == "text/markdown" or file.type == "text/md":
|
106 |
md = mistune.create_markdown()
|
107 |
content = md(file.read().decode())
|