Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (28 sloc) 580 Bytes
"""
Turn the following unix pipeline into Python code using generators
$ for i in ../*/*py; do grep ^import $i|sed 's/import //g' ; done | sort | uniq -c | sort -nr
4 unittest
4 sys
3 re
3 csv
2 tweepy
2 random
2 os
2 json
2 itertools
1 time
1 datetime
"""
def gen_files(pat):
pass
def gen_lines(files):
pass
def gen_grep(lines, pattern):
pass
def gen_count(lines):
pass
if __name__ == "__main__":
# call the generators, passing one to the other
files = gen_files('../*/*.py')
lines = gen_lines(files)
# etc