Created
August 23, 2017 13:29
-
-
Save dmihal/4d3eec476432092f8ec3b01ab60b5304 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
""" Convert sketch files to open with older versions of Sketch. | |
Based on https://sketchtalk.io/discussion/2546/file-backwards-compatibility | |
""" | |
__author__ = "David Mihal" | |
__license__ = "GPL" | |
import zipfile | |
import sys | |
import json | |
appVersion = "43.1" | |
build = 39012 | |
version = 88 | |
if len(sys.argv) == 1: | |
print "Usage: sketchCompatibility.py <drawing.sketch>" | |
exit() | |
filename = sys.argv[1] | |
newFilename = filename.replace('.sketch', '_compatable.sketch') | |
zin = zipfile.ZipFile (filename, 'r') | |
zout = zipfile.ZipFile (newFilename, 'w') | |
for item in zin.infolist(): | |
buffer = zin.read(item.filename) | |
if (item.filename == 'meta.json'): | |
meta = json.loads(buffer) | |
meta["version"] = version | |
meta["compatibilityVersion"] = version | |
meta["appVersion"] = appVersion | |
meta["build"] = build | |
meta['created']["appVersion"] = appVersion | |
meta['created']["build"] = build | |
meta['created']["compatibilityVersion"] = version | |
meta['created']["version"] = version | |
buffer = json.dumps(meta) | |
print buffer | |
zout.writestr(item, buffer) | |
zout.close() | |
zin.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment