Created
June 22, 2016 05:09
-
-
Save tbreeds/f250b964383922bdea4645740ae4b195 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/env python | |
from __future__ import print_function | |
import os | |
import packaging.utils | |
import packaging.requirements | |
import sys | |
try: | |
gr = sys.argv[1] | |
except IndexError: | |
gr = '~/projects/openstack/openstack/requirements/global-requirements.txt' | |
with open(os.path.expanduser(gr)) as gr: | |
for line in gr: | |
if line.startswith('#') or line == '\n': | |
print(line, end='') | |
else: | |
if '#' in line: | |
(line, _, license) = line.partition('#') | |
requirement = line.rstrip().lstrip() | |
r = packaging.requirements.Requirement(requirement) | |
r.name = packaging.utils.canonicalize_name(r.name) | |
print("%s #%s" %(r, license), end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment