Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 support #33

Open
wolph opened this issue Jul 7, 2017 · 2 comments
Open

Python 3 support #33

wolph opened this issue Jul 7, 2017 · 2 comments

Comments

@wolph
Copy link

wolph commented Jul 7, 2017

As far as I can see it would only change a few print statements and a str/basestr change. The patch as far as I can gather:

@@ -106,7 +106,7 @@
         in
     """
     fhash, read = hashlib.sha1(), 0
-    if isinstance(handle, basestring):
+    if isinstance(handle, str):
         handle = file(handle, 'rb')

     if limit:
@@ -250,7 +250,7 @@
                       pos + 1, group_count, fun_desc, count, len(paths)
                   ))

-        for key, group in classifier(paths, *args, **kwargs).items():
+        for key, group in list(classifier(paths, *args, **kwargs).items()):
             groups.setdefault(key, set()).update(group)
             count += len(group)

@@ -439,11 +439,11 @@
     :rtype: :class:`~__builtins__.int`
     """
     dupeList = sorted(dupeList)
-    print
+    print()
     for pos, val in enumerate(dupeList):
-        print "%d) %s" % (pos + 1, val)
+        print("%d) %s" % (pos + 1, val))
     while True:
-        choice = raw_input("[%s/%s] Keepers: " % (mainPos, mainLen)).strip()
+        choice = input("[%s/%s] Keepers: " % (mainPos, mainLen)).strip()
         if not choice:
             print ("Please enter a space/comma-separated list of numbers or "
                    "'all'.")
@@ -495,7 +495,7 @@
         value = DEFAULTS[key]
         if isinstance(value, (list, set)):
             value = ', '.join(value)
-        print "%*s: %s" % (maxlen, key, value)
+        print("%*s: %s" % (maxlen, key, value))

 def delete_dupes(groups, prefer_list=None, interactive=True, dry_run=False):
     """Code to handle the :option:`--delete` command-line option.
@@ -530,7 +530,7 @@

         assert preferred  # Safety check
         for path in pruneList:
-            print "Removing %s" % path
+            print("Removing %s" % path)
             if not dry_run:
                 os.remove(path)

@@ -598,8 +598,8 @@
         delete_dupes(groups, opts.prefer, not opts.noninteractive,
                      opts.dry_run)
     else:
-        for dupeSet in groups.values():
-            print '\n'.join(dupeSet) + '\n'
+        for dupeSet in list(groups.values()):
+            print('\n'.join(dupeSet) + '\n')

 if __name__ == '__main__':
     main()
@ssokolow
Copy link
Owner

ssokolow commented Jul 7, 2017

Probably. It's more that this project got put on the back burner before I started making a concerted effort to support Python 3.

I'm just recovering from the tail end of a cold that ended up rolling on into some nasty insomnia, but I'll leave this open and take a look as soon as I've finished catching up from that mess.

@ssokolow
Copy link
Owner

Sorry for going silent for so long.

I've started clearing out my backlogged issues now and the actual problem isn't that there aren't Python 3.x fixes, it's that I forgot to test and merge the missingfix branch where they exist.

I'll aim to get to work on that as soon as I get some responses to my comments on PR #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants