Skip to content

Instantly share code, notes, and snippets.

@paulwinex
Created October 30, 2016 10:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulwinex/d9583fa6d486df7cdee9e19b64486f68 to your computer and use it in GitHub Desktop.
Save paulwinex/d9583fa6d486df7cdee9e19b64486f68 to your computer and use it in GitHub Desktop.
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