else/Toolbox/unique.py
Ethan Dalool 97403c7d5f else
2016-12-04 17:50:52 -08:00

22 lines
410 B
Python

'''
Keep the unique lines coming from stdin and print them.
'''
from voussoirkit import clipext
import sys
if len(sys.argv) > 1:
text = clipext.resolve(sys.argv[1])
else:
text = clipext.resolve('!input')
text = text.split('\n')
new_text = []
seen = set()
for item in text:
if item not in seen:
new_text.append(item)
seen.add(item)
new_text = '\n'.join(new_text)
print(new_text)