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