Make do_uniq work with python3

Approved by:	cperciva
MFC after:	3 days
This commit is contained in:
Eitan Adler 2012-10-22 02:29:56 +00:00
parent 7a1595e33b
commit 1acb71e699

View File

@ -34,26 +34,26 @@ def edit(datfile):
for line in file(datfile): for line in file(datfile):
if line == "%\n": if line == "%\n":
key = hash(fortune) key = hash(fortune)
if not dups.has_key(key): if key not in dups:
dups[key] = [] dups[key] = []
dups[key].append(fortune) dups[key].append(fortune)
fortunes.append(fortune) fortunes.append(fortune)
fortune = "" fortune = ""
else: else:
fortune += line fortune += line
for key in dups.keys(): for key in list(dups.keys()):
if len(dups[key]) == 1: if len(dups[key]) == 1:
del dups[key] del dups[key]
o = file(datfile + '~', "w") o = file(datfile + '~', "w")
for fortune in fortunes: for fortune in fortunes:
key = hash(fortune) key = hash(fortune)
if key in dups: if key in dups:
print '\n' * 50 print('\n' * 50)
for f in dups[key]: for f in dups[key]:
if f != fortune: if f != fortune:
print f, '%' print(f, '%')
print fortune, '%' print(fortune, '%')
if raw_input("Remove last fortune? ") == 'y': if input("Remove last fortune? ") == 'y':
del dups[key] del dups[key]
continue continue
o.write(fortune + "%\n") o.write(fortune + "%\n")