import pprint
import argparse
import mutators
from algorithms.password_leaner import password_leaner
from algorithms.tokeniser import tokeniser
from algorithms import generators
from random import shuffle

pp = pprint.PrettyPrinter(indent=1)


def justGetPassword(password):

    count = 0
    for i in range(len(password)-1,0,-1):
        if(password[i] != ' '):
            count+=1
        else:
            break

    return password[len(password)-count:len(password)]


def main(password, number):

    honeywords = [password]

    database_size = 1000
    database_count = 1
    database = []
    for line in open("resources/rockyou-withcount.txt"):
        database.append(justGetPassword(line[:-1]))
        database_count += 1
        if database_count > database_size:
            break

    print database[0]
    print len(database)

    for i in range(number):
        nicolasObject = password_leaner(password)
        rishavObject = tokeniser(nicolasObject)
        markObject = generators.generateHoneyWord(rishavObject, database)
        #pp.pprint(rishavObject)
        pp.pprint(markObject)

    shuffle(honeywords)
    return honeywords


parser = argparse.ArgumentParser(description='Generate honey words from a list '
                                             'of passwords')

parser.add_argument('n', type=int)
parser.add_argument('input_passwords_file', type=file)
parser.add_argument('output_passwords_file', type=argparse.FileType('w+'))

args = parser.parse_args()

for password in args.input_passwords_file:
    args.output_passwords_file.write(",".join(main(password, args.n)) + "\n")

"""
pp.pprint(password_leaner("!!n0t.@n0th3r.d@mn.p@$$w0rd!!"))
print mutators.numbers.mutate_all_odds("135")
print mutators.numbers.mutate_all_even("028")
print mutators.numbers.mutate_random("2398")
print mutators.numbers.mutate_sequence("2345")

print mutators.strings.mutate_leet_speak("another")
print mutators.strings.mutate_sequence("abc")
print mutators.strings.change_semantic_word("another")
print mutators.strings.mutate_constant("aaaa")
print mutators.strings.mutate_random("lashdkj")
print mutators.strings.mutate_caps("iuywebn")
"""

@@ -1079,25 +1079,33 @@
         
-pp.pprint
+honeywords.append
 (markObj
@@ -1107,16 +1107,24 @@
 rkObject
+.strip()
 )%0A%0A    s
@@ -1142,16 +1142,37 @@
 ywords)%0A
+    print honeywords%0A
     retu
@@ -1575,83 +1575,144 @@
     
-args.output_passwords_file.write(%22,%22.join(main(password, args.n)) + 
+for honey in main(password, args.n):%0A        args.output_passwords_file.write(honey + %22,%22)%0A    args.output_passwords_file.write(
 %22%5Cn%22)%0A%0A
+%0A
 %22%22%22%0A

Fix some append problem