Last active
April 28, 2016 21:40
-
-
Save Spacerat/7fb30b1cd4c7f6b54c38ba0559c10876 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 | |
# Quick and dirty script to scrub pip requirements files of duplicate requirements | |
import sys | |
import fileinput | |
from requirements.requirement import Requirement | |
seen = set() | |
out = [] | |
for line in fileinput.input(): | |
try: | |
name = Requirement.parse(line).name | |
if name in seen: | |
continue | |
seen.add(name) | |
sys.stdout.write(line) | |
except ValueError as e: | |
sys.stdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment