-
-
Save nelsestu/d6b4933221a7867da47fbe94d3c3c00d 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 | |
#coding:utf-8 | |
import json, toml, hashlib | |
groups = { | |
'default': [], | |
'develop': [] | |
} | |
# Open the Pipfile. | |
with open("Pipfile") as f: | |
content = f.read() | |
# Load the default configuration. | |
default_config = { | |
u'source': [{u'url': u'https://pypi.python.org/simple', u'verify_ssl': True, 'name': "pypi"}], | |
u'packages': {}, | |
u'requires': {}, | |
u'dev-packages': {} | |
} | |
config = {} | |
config.update(default_config) | |
# Deserialize the TOML, and parse for Environment Variables | |
parsed = toml.loads(content) | |
config.update(parsed) | |
# Structure the data for output. | |
data = { | |
'_meta': { | |
'sources': config['source'], | |
'requires': config['requires'] | |
}, | |
} | |
groups['default'] = config['packages'] | |
groups['develop'] = config['dev-packages'] | |
# Update the data structure with group information. | |
data.update(groups) | |
content = json.dumps(data, sort_keys=True, separators=(",", ":")) | |
print(hashlib.sha256(content.encode("utf8")).hexdigest()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment