Created
May 10, 2022 06:39
-
-
Save tvogels/e86b06bde411354df507203ede1fa5ad to your computer and use it in GitHub Desktop.
Read a Sketch file in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
from zipfile import ZipFile | |
import hashlib | |
import json | |
zipf = ZipFile("slides.sketch") | |
with tempfile.TemporaryDirectory() as d: | |
for file in zipf.infolist(): | |
if file.filename.startswith("pages/"): | |
outfile = zipf.extract(file.filename, d) | |
with open(outfile, "r") as fp: | |
layers = json.load(fp)["layers"] | |
for layer in layers: | |
print(layer["name"]) | |
print(hashlib.md5(json.dumps(layer).encode("utf-8")).hexdigest()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment