mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Initial pass of removing Python 2 support
This commit removes Six as a dependency for Pelican, replacing the relevant aliases with the proper Python 3 imports. It also removes references to Python 2 logic that did not require Six.
This commit is contained in:
parent
ae73d06301
commit
1e0e541b57
43 changed files with 126 additions and 459 deletions
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
AUTHOR = 'Alexis Métaireau'
|
||||
SITENAME = "Alexis' log"
|
||||
SITEURL = 'http://blog.notmyidea.org'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import locale
|
||||
import logging
|
||||
|
|
@ -10,12 +9,11 @@ import sys
|
|||
import unittest
|
||||
from contextlib import contextmanager
|
||||
from functools import wraps
|
||||
from io import StringIO
|
||||
from logging.handlers import BufferingHandler
|
||||
from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
|
||||
from six import StringIO
|
||||
|
||||
from pelican.contents import Article
|
||||
from pelican.readers import default_metadata
|
||||
from pelican.settings import DEFAULT_CONFIG
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
from shutil import rmtree
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import datetime
|
||||
import locale
|
||||
import logging
|
||||
import os.path
|
||||
|
|
@ -9,15 +9,12 @@ from sys import platform
|
|||
|
||||
from jinja2.utils import generate_lorem_ipsum
|
||||
|
||||
import six
|
||||
|
||||
from pelican.contents import Article, Author, Category, Page, Static
|
||||
from pelican.settings import DEFAULT_CONFIG
|
||||
from pelican.signals import content_object_init
|
||||
from pelican.tests.support import (LoggedTestCase, get_context, get_settings,
|
||||
unittest)
|
||||
from pelican.utils import (SafeDatetime, path_to_url, posixize_path,
|
||||
truncate_html_words)
|
||||
from pelican.utils import (path_to_url, posixize_path, truncate_html_words)
|
||||
|
||||
|
||||
# generate one paragraph, enclosed with <p>
|
||||
|
|
@ -185,7 +182,7 @@ class TestPage(LoggedTestCase):
|
|||
|
||||
def test_datetime(self):
|
||||
# If DATETIME is set to a tuple, it should be used to override LOCALE
|
||||
dt = SafeDatetime(2015, 9, 13)
|
||||
dt = datetime.datetime(2015, 9, 13)
|
||||
|
||||
page_kwargs = self._copy_page_kwargs()
|
||||
|
||||
|
|
@ -286,9 +283,7 @@ class TestPage(LoggedTestCase):
|
|||
'<a href="http://notmyidea.org/category/category.html">link</a>'))
|
||||
|
||||
def test_intrasite_link(self):
|
||||
# type does not take unicode in PY2 and bytes in PY3, which in
|
||||
# combination with unicode literals leads to following insane line:
|
||||
cls_name = '_DummyArticle' if six.PY3 else b'_DummyArticle'
|
||||
cls_name = '_DummyArticle'
|
||||
article = type(cls_name, (object,), {'url': 'article.html'})
|
||||
|
||||
args = self.page_kwargs.copy()
|
||||
|
|
@ -370,9 +365,7 @@ class TestPage(LoggedTestCase):
|
|||
self.assertEqual(p.custom, linked)
|
||||
|
||||
def test_intrasite_link_more(self):
|
||||
# type does not take unicode in PY2 and bytes in PY3, which in
|
||||
# combination with unicode literals leads to following insane line:
|
||||
cls_name = '_DummyAsset' if six.PY3 else b'_DummyAsset'
|
||||
cls_name = '_DummyAsset'
|
||||
|
||||
args = self.page_kwargs.copy()
|
||||
args['settings'] = get_settings()
|
||||
|
|
@ -487,9 +480,7 @@ class TestPage(LoggedTestCase):
|
|||
)
|
||||
|
||||
def test_intrasite_link_markdown_spaces(self):
|
||||
# Markdown introduces %20 instead of spaces, this tests that
|
||||
# we support markdown doing this.
|
||||
cls_name = '_DummyArticle' if six.PY3 else b'_DummyArticle'
|
||||
cls_name = '_DummyArticle'
|
||||
article = type(cls_name, (object,), {'url': 'article-spaces.html'})
|
||||
|
||||
args = self.page_kwargs.copy()
|
||||
|
|
@ -512,7 +503,7 @@ class TestPage(LoggedTestCase):
|
|||
def test_intrasite_link_source_and_generated(self):
|
||||
"""Test linking both to the source and the generated article
|
||||
"""
|
||||
cls_name = '_DummyAsset' if six.PY3 else b'_DummyAsset'
|
||||
cls_name = '_DummyAsset'
|
||||
|
||||
args = self.page_kwargs.copy()
|
||||
args['settings'] = get_settings()
|
||||
|
|
@ -538,7 +529,7 @@ class TestPage(LoggedTestCase):
|
|||
def test_intrasite_link_to_static_content_with_filename(self):
|
||||
"""Test linking to a static resource with deprecated {filename}
|
||||
"""
|
||||
cls_name = '_DummyAsset' if six.PY3 else b'_DummyAsset'
|
||||
cls_name = '_DummyAsset'
|
||||
|
||||
args = self.page_kwargs.copy()
|
||||
args['settings'] = get_settings()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import locale
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import locale
|
||||
import os
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import locale
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
try:
|
||||
import collections.abc as collections
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
from pelican import readers
|
||||
from pelican.tests.support import get_settings, unittest
|
||||
from pelican.utils import SafeDatetime
|
||||
|
|
@ -64,8 +61,7 @@ class TestAssertDictHasSubset(ReaderTest):
|
|||
self.assertDictHasSubset(self.dictionary, self.dictionary)
|
||||
|
||||
def test_fail_not_set(self):
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
self.assertRaisesRegex(
|
||||
AssertionError,
|
||||
r'Expected.*key-c.*to have value.*val-c.*but was not in Dict',
|
||||
self.assertDictHasSubset,
|
||||
|
|
@ -73,8 +69,7 @@ class TestAssertDictHasSubset(ReaderTest):
|
|||
{'key-c': 'val-c'})
|
||||
|
||||
def test_fail_wrong_val(self):
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
self.assertRaisesRegex(
|
||||
AssertionError,
|
||||
r'Expected .*key-a.* to have value .*val-b.* but was .*val-a.*',
|
||||
self.assertDictHasSubset,
|
||||
|
|
@ -445,7 +440,7 @@ class RstReaderTest(ReaderTest):
|
|||
def test_parse_error(self):
|
||||
# Verify that it raises an Exception, not nothing and not SystemExit or
|
||||
# some such
|
||||
with six.assertRaisesRegex(self, Exception, "underline too short"):
|
||||
with self.assertRaisesRegex(Exception, "underline too short"):
|
||||
self.read_file(path='../parse_error/parse_error.rst')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from pelican.tests.support import unittest
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import os
|
||||
from io import BytesIO
|
||||
from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
|
||||
from six import BytesIO
|
||||
|
||||
from pelican.server import ComplexHTTPRequestHandler
|
||||
from pelican.tests.support import unittest
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import copy
|
||||
import locale
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import warnings
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from pelican.tests.support import unittest
|
||||
from pelican.urlwrappers import Author, Category, Tag, URLWrapper
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import locale
|
||||
import logging
|
||||
|
|
@ -11,8 +10,6 @@ from tempfile import mkdtemp
|
|||
|
||||
import pytz
|
||||
|
||||
import six
|
||||
|
||||
from pelican import utils
|
||||
from pelican.generators import TemplatePagesGenerator
|
||||
from pelican.settings import read_settings
|
||||
|
|
@ -720,8 +717,7 @@ class TestSanitisedJoin(unittest.TestCase):
|
|||
@unittest.skipIf(platform == 'win32',
|
||||
"Different filesystem root on Windows")
|
||||
def test_detect_parent_breakout(self):
|
||||
with six.assertRaisesRegex(
|
||||
self,
|
||||
with self.assertRaisesRegex(
|
||||
RuntimeError,
|
||||
"Attempted to break out of output directory to /foo/test"):
|
||||
utils.sanitised_join(
|
||||
|
|
@ -732,8 +728,7 @@ class TestSanitisedJoin(unittest.TestCase):
|
|||
@unittest.skipIf(platform == 'win32',
|
||||
"Different filesystem root on Windows")
|
||||
def test_detect_root_breakout(self):
|
||||
with six.assertRaisesRegex(
|
||||
self,
|
||||
with self.assertRaisesRegex(
|
||||
RuntimeError,
|
||||
"Attempted to break out of output directory to /test"):
|
||||
utils.sanitised_join(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue