Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created September 24, 2014 17:20
Show Gist options
  • Save mythmon/bd828d880fe14a0066b8 to your computer and use it in GitHub Desktop.
Save mythmon/bd828d880fe14a0066b8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re
req_path = 'requirements/default.txt'
requirements = []
acc = ''
with open(req_path) as f:
for line in f:
if line.strip() == '':
continue
acc += line
if not line.startswith('#'):
requirements.append(acc)
acc = ''
def sort_name(req):
lines = filter(lambda s: s != '', req.split('\n'))
name = lines[-1]
match = re.match(r'^https?://.*#egg=(.*)$', name)
if match:
name = match.group(1)
else:
name = name[:name.find('==')]
name = name.lower()
return name
for req in sorted(requirements, key=sort_name):
print req
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment