Skip to content

Instantly share code, notes, and snippets.

@lolsborn
Created June 14, 2012 17:36
Show Gist options
  • Save lolsborn/2931656 to your computer and use it in GitHub Desktop.
Save lolsborn/2931656 to your computer and use it in GitHub Desktop.
sha1 manifest in json for [redacted]
#!/usr/bin/env python
import hashlib
import json
import glob
import sys
import os
pass_path = "%s/*" % sys.argv[1]
manifest = {}
for file_path in glob.glob(pass_path):
if os.path.isfile(file_path):
file_name = file_path[len(sys.argv[1]) + 1:]
if file_path.endswith("manifest.json"):
continue
manifest[file_name] = hashlib.sha1(open(file_path, "rb").read()).hexdigest()
else:
print "not file", file_path
manifest_file = open("%s/manifest.json" % sys.argv[1], "w")
manifest_file.write(json.dumps(manifest, sort_keys=True, indent=4))
#!/usr/bin/env python
import hashlib
import json
import glob
import sys
import os
pass_path = "%s/*" % sys.argv[1]
manifest = {}
for file_path in glob.glob(pass_path):
if os.path.isfile(file_path):
file_name = file_path[len(sys.argv[1]) + 1:]
if file_path.endswith("manifest.json"):
continue
manifest[file_name] = hashlib.sha1(open(file_path, "rb").read()).hexdigest()
else:
print "not file", file_path
manifest_file = open("%s/manifest.json" % sys.argv[1], "w")
manifest_file.write(json.dumps(manifest, sort_keys=True, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment