Created
October 15, 2014 04:12
-
-
Save nicovillanueva/7f7fb25a3edb5bd2b59c to your computer and use it in GitHub Desktop.
Split & sort
This file contains hidden or 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
import argparse | |
def split_logins(logins): | |
for each in logins: | |
yield each.split(":") | |
parser = argparse.ArgumentParser() | |
parser.add_argument('lists', type=str, nargs='+') | |
args = parser.parse_args() | |
print("Parsing: " + str(args.lists)) | |
logins = [] | |
for each in args.lists: | |
with open(each) as f: | |
lines = f.readlines() | |
[logins.append(line[:-1]) for line in lines if ":" in line and " " not in line] | |
mails, pwds = zip(*split_logins(logins)) | |
sorted_pwds = sorted(pwds, key=lambda p: len(p), reverse=True) | |
longest_pwds = sorted_pwds[:5] | |
shortest_pwds = sorted_pwds[-5:] | |
print(longest_pwds) | |
print(shortest_pwds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment