Created
October 30, 2016 10:01
-
-
Save paulwinex/d9583fa6d486df7cdee9e19b64486f68 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
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