mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-17 06:20:27 +00:00
Python3: use str and basestring from builtins
This commit is contained in:
parent
e93d18d6e9
commit
8f4acc3168
5 changed files with 15 additions and 6 deletions
|
|
@ -22,6 +22,7 @@ except ImportError: # Python 2
|
|||
from ConfigParser import RawConfigParser
|
||||
import os
|
||||
from .. import LinkCheckerError, get_link_pat, LOG_CHECK, log, fileutil, plugins, logconf
|
||||
from builtins import str
|
||||
|
||||
|
||||
def read_multiline (value):
|
||||
|
|
@ -62,7 +63,7 @@ class LCConfigParser (RawConfigParser, object):
|
|||
self.read_plugin_config()
|
||||
except Exception as msg:
|
||||
raise LinkCheckerError(
|
||||
_("Error parsing configuration: %s") % unicode(msg))
|
||||
_("Error parsing configuration: %s") % str(msg))
|
||||
|
||||
def read_string_option (self, section, option, allowempty=False):
|
||||
"""Read a string option."""
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ Special container classes.
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
from past.builtins import basestring
|
||||
|
||||
class AttrDict (dict):
|
||||
"""Dictionary allowing attribute access to its elements if they
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@ Test config parsing.
|
|||
import unittest
|
||||
import os
|
||||
import linkcheck.configuration
|
||||
from builtins import str
|
||||
|
||||
|
||||
def get_file (filename=None):
|
||||
"""Get file name located within 'data' directory."""
|
||||
directory = os.path.join("tests", "configuration", "data")
|
||||
if filename:
|
||||
return unicode(os.path.join(directory, filename))
|
||||
return unicode(directory)
|
||||
return str(os.path.join(directory, filename))
|
||||
return str(directory)
|
||||
|
||||
|
||||
class TestConfig (unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@
|
|||
Test dummy object.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from builtins import bytes, str
|
||||
|
||||
import linkcheck.dummy
|
||||
|
||||
|
||||
|
|
@ -60,4 +64,5 @@ class TestDummy (unittest.TestCase):
|
|||
del dummy[2:3]
|
||||
str(dummy)
|
||||
repr(dummy)
|
||||
unicode(dummy)
|
||||
if sys.version_info.major == 2:
|
||||
unicode(dummy)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Test update check functionality.
|
|||
import unittest
|
||||
from tests import need_network
|
||||
import linkcheck.updater
|
||||
from builtins import str
|
||||
|
||||
|
||||
class TestUpdater (unittest.TestCase):
|
||||
|
|
@ -35,7 +36,7 @@ class TestUpdater (unittest.TestCase):
|
|||
if isinstance(value, tuple):
|
||||
self.assertEqual(len(value), 2)
|
||||
version, url = value
|
||||
self.assertTrue(isinstance(version, basestring), repr(version))
|
||||
self.assertTrue(url is None or isinstance(url, basestring), repr(url))
|
||||
self.assertTrue(isinstance(version, str), repr(version))
|
||||
self.assertTrue(url is None or isinstance(url, str), repr(url))
|
||||
else:
|
||||
self.assertTrue(isinstance(value, unicode), repr(value))
|
||||
|
|
|
|||
Loading…
Reference in a new issue