mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-10-26 21:19:04 +08:00
fix: remove lfs usage of tree.xml and revert to biggest possible version
Sadly we can no longer update this file as it reached 100MB and that's the max size allowed on GitHub to have files, we could only increase it further by paying for the bandwidth
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import base64
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
def generate_folder_tree(paths):
|
||||
tree = {}
|
||||
@@ -22,31 +21,6 @@ def generate_folder_tree(paths):
|
||||
webp_files.append(os.path.join(root, file))
|
||||
return tree, webp_files
|
||||
|
||||
def generate_webp_xml(webp_files):
|
||||
json_obj_list = []
|
||||
for path in webp_files:
|
||||
with open(path, "rb") as image_file:
|
||||
# Encode the WebP image to base64
|
||||
data = base64.b64encode(image_file.read()).decode('ascii')
|
||||
|
||||
# Build the base64 string for data URI
|
||||
data_string = f"data:image/webp;base64,{data}"
|
||||
|
||||
# Extract name from the path
|
||||
name = Path(path).stem
|
||||
|
||||
# Append the base64 encoded WebP data into the list
|
||||
json_obj_list.append({
|
||||
"data": data_string,
|
||||
"w": 48,
|
||||
"h": 48,
|
||||
"title": name,
|
||||
"aspect": "fixed"
|
||||
})
|
||||
|
||||
# Convert to JSON string with no extra spaces for XML output
|
||||
return json.dumps(json_obj_list, separators=(',', ':'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Adjust paths to be one level up
|
||||
folder_paths = sys.argv[1:]
|
||||
@@ -64,16 +38,4 @@ if __name__ == "__main__":
|
||||
tree_json_path = root_dir.parent / 'tree.json'
|
||||
with open(tree_json_path, 'w') as f:
|
||||
json.dump(folder_tree, f, indent=4, sort_keys=True) # Sort the keys in the JSON output
|
||||
print(f"Folder tree successfully written to '{tree_json_path}'.")
|
||||
|
||||
# Generate WebP XML
|
||||
if webp_files:
|
||||
webp_json = generate_webp_xml(webp_files)
|
||||
|
||||
# Write XML structure (with wrapped JSON) to 'tree.xml'
|
||||
xml_output_path = root_dir.parent / 'tree.xml'
|
||||
with open(xml_output_path, 'w') as xml_output:
|
||||
print(f"<mxlibrary>{webp_json}</mxlibrary>", file=xml_output)
|
||||
print(f"WebP assets successfully written to '{xml_output_path}'.")
|
||||
else:
|
||||
print("No WebP files found for XML generation.")
|
||||
print(f"Folder tree successfully written to '{tree_json_path}'.")
|
||||
Reference in New Issue
Block a user