#!/usr/bin/env python

import string
import random
import gzip
import os.path
from Crypto.Random import random

FILENAMES=[
	'/usr/share/ispell/american.mwl.gz',
	'/usr/share/ispell/british.mwl.gz',
	]


def ok_word( word):
	letter = not any((c not in string.ascii_lowercase) for c in word)
	size = 3 < len( word)
	nono = word in ['fuck', 'fucker', 'cock']
	return letter and size and not nono

def clean( word):
	return word[:word.find('/')]

for filename in [x for x in FILENAMES if os.path.isfile( x)]:
	with gzip.open( filename, 'rb') as f:
		all_words = f.readlines()

clean_dict = [clean( word) for word in all_words]
dictionary = [word for word in clean_dict if ok_word( word)]

#print 'Dictionary length: ', len(dictionary)

pwd_words = [random.choice( dictionary) for _ in range(0,4)]
print '.'.join( pwd_words)


