Instantly share code, notes, and snippets.

Embed
What would you like to do?
import cask, shutil, json
def save_meta(path, meta):
tmp = path+'.tmp'
shutil.copy2(path, tmp)
a = cask.Archive(tmp)
#exists_prop = a.top.properties
pr = cask.Property()
pr.set_value(json.dumps(meta))
a.top.properties['jmeta'] = pr
#for k, v in exists_prop.items():
# a.top.properties[k] = v
a.write_to_file(path, 1)
a.close()
a = None
del a
os.remove(tmp)
def read_meta(path):
a = cask.Archive(path)
out = {}
if a.top.properties.get('jmeta'):
out = json.loads(a.top.properties['jmeta'].get_value())
a.close()
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment