[Midnightbsd-cvs] src [8271] trunk/games/fortune/tools/do_uniq.py: more python 3 hacks

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Sep 17 17:52:19 EDT 2016


Revision: 8271
          http://svnweb.midnightbsd.org/src/?rev=8271
Author:   laffer1
Date:     2016-09-17 17:52:19 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
more python 3 hacks

Modified Paths:
--------------
    trunk/games/fortune/tools/do_uniq.py

Modified: trunk/games/fortune/tools/do_uniq.py
===================================================================
--- trunk/games/fortune/tools/do_uniq.py	2016-09-17 21:50:29 UTC (rev 8270)
+++ trunk/games/fortune/tools/do_uniq.py	2016-09-17 21:52:19 UTC (rev 8271)
@@ -35,7 +35,7 @@
     for line in file(datfile):
         if line == "%\n":
             key = hash(fortune)
-            if not dups.has_key(key):
+            if key not in dups:
                 dups[key] = []
             dups[key].append(fortune)
             fortunes.append(fortune)
@@ -42,7 +42,7 @@
             fortune = ""
         else:
             fortune += line
-    for key in dups.keys():
+    for key in list(dups.keys()):
         if len(dups[key]) == 1:
             del dups[key]
     o = file(datfile + '~', "w")
@@ -49,12 +49,12 @@
     for fortune in fortunes:
         key = hash(fortune)
         if key in dups:
-            print '\n' * 50
+            print('\n' * 50)
             for f in dups[key]:
                 if f != fortune:
-                    print f, '%'
-            print fortune, '%'
-            if raw_input("Remove last fortune? ") == 'y':
+                    print(f, '%')
+            print(fortune, '%')
+            if input("Remove last fortune? ") == 'y':
                 del dups[key]
                 continue
         o.write(fortune + "%\n")



More information about the Midnightbsd-cvs mailing list