Skip to content

Remove deprecated code #169

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

Merged
merged 4 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions tests/test_form.py

This file was deleted.

5 changes: 0 additions & 5 deletions tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
safe_url_string,
url_query_parameter,
url_query_cleaner,
urljoin_rfc,
)


Expand Down Expand Up @@ -462,10 +461,6 @@ def test_any_to_uri(self):
self.assertEqual(any_to_uri("http://www.example.com/some/path.txt"),
"http://www.example.com/some/path.txt")

def test_urljoin_rfc_deprecated(self):
jurl = urljoin_rfc("http://www.example.com/", "/test")
self.assertEqual(jurl, b"http://www.example.com/test")


class CanonicalizeUrlTest(unittest.TestCase):

Expand Down
65 changes: 0 additions & 65 deletions w3lib/form.py

This file was deleted.

19 changes: 0 additions & 19 deletions w3lib/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Functions for dealing with markup text
"""

import warnings
import re
from html.entities import name2codepoint
from urllib.parse import urljoin
Expand All @@ -19,24 +18,6 @@
HTML5_WHITESPACE = ' \t\n\r\x0c'


def remove_entities(text, keep=(), remove_illegal=True, encoding='utf-8'):
r"""

.. warning::

This function is deprecated and will be removed in future.
Please use :func:`replace_entities` instead.
"""

warnings.warn(
"`w3lib.html.remove_entities` function is deprecated and "
"will be removed in future releases. Please use "
"`w3lib.html.replace_entities` instead.",
DeprecationWarning
)

return replace_entities(text, keep, remove_illegal, encoding)

def replace_entities(text, keep=(), remove_illegal=True, encoding='utf-8'):
"""Remove entities from the given `text` by converting them to their
corresponding unicode character.
Expand Down
66 changes: 14 additions & 52 deletions w3lib/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import posixpath
import re
import string
import warnings
from collections import namedtuple
from urllib.parse import (
_coerce_args,
Expand All @@ -19,7 +18,6 @@
unquote_to_bytes,
urldefrag,
urlencode,
urljoin,
urlparse,
urlsplit,
urlunparse,
Expand Down Expand Up @@ -392,21 +390,20 @@ def parse_data_uri(uri):
return _ParseDataURIResult(media_type, media_type_params, data)


__all__ = ["add_or_replace_parameter",
"add_or_replace_parameters",
"any_to_uri",
"canonicalize_url",
"file_uri_to_path",
"is_url",
"parse_data_uri",
"path_to_file_uri",
"safe_download_url",
"safe_url_string",
"url_query_cleaner",
"url_query_parameter",

# this last one is deprecated ; include it to be on the safe side
"urljoin_rfc"]
__all__ = [
"add_or_replace_parameter",
"add_or_replace_parameters",
"any_to_uri",
"canonicalize_url",
"file_uri_to_path",
"is_url",
"parse_data_uri",
"path_to_file_uri",
"safe_download_url",
"safe_url_string",
"url_query_cleaner",
"url_query_parameter",
]


def _safe_ParseResult(parts, encoding='utf8', path_encoding='utf8'):
Expand Down Expand Up @@ -585,38 +582,3 @@ def parse_qsl_to_bytes(qs, keep_blank_values=False):
value = _coerce_result(value)
r.append((name, value))
return r


def urljoin_rfc(base, ref, encoding='utf-8'):
r"""
.. warning::

This function is deprecated and will be removed in future.
It is not supported with Python 3.
Please use ``urlparse.urljoin`` instead.

Same as urlparse.urljoin but supports unicode values in base and ref
parameters (in which case they will be converted to str using the given
encoding).

Always returns a str.

>>> import w3lib.url
>>> w3lib.url.urljoin_rfc('http://www.example.com/path/index.html', '/otherpath/index2.html')
'http://www.example.com/otherpath/index2.html'
>>>

>>> # Note: the following does not work in Python 3
>>> w3lib.url.urljoin_rfc(b'http://www.example.com/path/index.html', 'fran\u00e7ais/d\u00e9part.htm') # doctest: +SKIP
'http://www.example.com/path/fran\xc3\xa7ais/d\xc3\xa9part.htm'
>>>


"""

warnings.warn("w3lib.url.urljoin_rfc is deprecated, use urlparse.urljoin instead",
DeprecationWarning)

str_base = to_bytes(base, encoding)
str_ref = to_bytes(ref, encoding)
return urljoin(str_base, str_ref)