diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-02-24 10:44:53 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-02-24 10:44:53 +0100 |
commit | 2ca83d087d32a4a30597af0e60d7927c64f46153 (patch) | |
tree | d1bd2c793b42a2c4b16511ca45032f9e3b051d1a | |
parent | dfcee1393714dde8761833ca13aa302309d124eb (diff) | |
download | urlgrabber-2ca83d087d32a4a30597af0e60d7927c64f46153.tar.gz |
Replace some type() with specific class names
We know what the types of basic types are, let's just put that directly in the code.
It seems more idiomatic and slightly more efficient to do things this way.
-rw-r--r-- | test/munittest.py | 4 | ||||
-rw-r--r-- | urlgrabber/grabber.py | 2 | ||||
-rw-r--r-- | urlgrabber/mirror.py | 2 | ||||
-rw-r--r-- | urlgrabber/progress.py | 4 |
4 files changed, 6 insertions, 6 deletions
diff --git a/test/munittest.py b/test/munittest.py index 2a7eaf8..e41d7c9 100644 --- a/test/munittest.py +++ b/test/munittest.py @@ -108,7 +108,7 @@ import os import types import unittest -from six import class_types +from six import class_types, string_types try: cmp @@ -846,7 +846,7 @@ Examples: """ def __init__(self, module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=defaultTestLoader): - if isinstance(module, type('')): + if isinstance(module, string_types): self.module = __import__(module) for part in module.split('.')[1:]: self.module = getattr(self.module, part) diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py index 0a26fb4..82d69dd 100644 --- a/urlgrabber/grabber.py +++ b/urlgrabber/grabber.py @@ -946,7 +946,7 @@ class URLGrabberOptions: """ if self.throttle <= 0: return 0 - elif isinstance(self.throttle, type(0)): + elif isinstance(self.throttle, int): return float(self.throttle) else: # throttle is a float return self.bandwidth * self.throttle diff --git a/urlgrabber/mirror.py b/urlgrabber/mirror.py index 1d7fd3d..75f0bcb 100644 --- a/urlgrabber/mirror.py +++ b/urlgrabber/mirror.py @@ -324,7 +324,7 @@ class MirrorGroup: # the callback) cb = gr.kw.get('failure_callback') or self.failure_callback if cb: - if isinstance(cb, type( () )): + if isinstance(cb, tuple): cb, args, kwargs = cb else: args, kwargs = (), {} diff --git a/urlgrabber/progress.py b/urlgrabber/progress.py index 4867527..1cf29d2 100644 --- a/urlgrabber/progress.py +++ b/urlgrabber/progress.py @@ -32,7 +32,7 @@ if sys.version_info >= (3,): else: import thread -from six import integer_types +from six import integer_types, string_types # Code from http://mail.python.org/pipermail/python-list/2000-May/033365.html def terminal_width(fd=1): @@ -614,7 +614,7 @@ class TextMultiFileMeter(MultiFileMeter): try: format = "%-30.30s %6.6s %s" fn = meter.text or meter.basename - if type(message) in (type(''), type(u'')): + if isinstance(message, string_types): message = message.splitlines() if not message: message = [''] out = '%-79s' % (format % (fn, 'FAILED', message[0] or '')) |