Hello community,
here is the log from the commit of package python-requests-toolbelt for openSUSE:Factory checked in at 2017-07-04 11:58:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-requests-toolbelt (Old)
and /work/SRC/openSUSE:Factory/.python-requests-toolbelt.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-requests-toolbelt"
Tue Jul 4 11:58:23 2017 rev:3 rq:507986 version:0.8.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-requests-toolbelt/python-requests-toolbelt.changes 2017-05-17 10:55:18.530769201 +0200
+++ /work/SRC/openSUSE:Factory/.python-requests-toolbelt.new/python-requests-toolbelt.changes 2017-07-04 11:58:26.460974825 +0200
@@ -1,0 +2,6 @@
+Fri Jun 30 16:59:55 UTC 2017 - aloisio@gmx.com
+
+- Update to version 0.8.0 (see HISTORY.rst)
+- Converted to single-spec
+
+-------------------------------------------------------------------
Old:
----
requests-toolbelt-0.7.0.tar.gz
New:
----
requests-toolbelt-0.8.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-requests-toolbelt.spec ++++++
--- /var/tmp/diff_new_pack.Lg4ib4/_old 2017-07-04 11:58:27.956764328 +0200
+++ /var/tmp/diff_new_pack.Lg4ib4/_new 2017-07-04 11:58:27.960763765 +0200
@@ -16,45 +16,52 @@
#
-%define short_name requests-toolbelt
-
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-requests-toolbelt
-Version: 0.7.0
+Version: 0.8.0
Release: 0
-Summary: Utility belt for advanced users of python-requests
+Summary: A utility belt for advanced users of python3-requests
License: Apache-2.0
Group: Development/Languages/Python
-Url: https://pypi.io/packages/source/r/requests-toolbelt/%{version}
-Source: %{short_name}-%{version}.tar.gz
+Url: https://toolbelt.readthedocs.org
+Source: https://files.pythonhosted.org/packages/source/r/requests-toolbelt/requests-toolbelt-%{version}.tar.gz
+BuildRequires: %{python_module requests >= 2.0.1}
+BuildRequires: %{python_module setuptools}
+# SECTION test requirements
BuildRequires: %{python_module betamax}
BuildRequires: %{python_module mock}
BuildRequires: %{python_module pytest}
-BuildRequires: %{python_module requests}
-BuildRequires: %{python_module setuptools}
+# /SECTION
+BuildRequires: fdupes
BuildRequires: python-rpm-macros
-Requires: %{python_module requests}
+Requires: python-requests >= 2.0.1
BuildRoot: %{_tmppath}/%{name}-%{version}-build
+BuildArch: noarch
%python_subpackages
%description
-This is just a collection of utilities for python-requests, but don't really belong in requests proper. The minimum tested requests version is 2.1.0. In reality, the toolbelt should work with 2.0.1 as well, but some idiosyncracies prevent effective or sane testing on that version.
+This is just a collection of utilities for `python-requests`_, but don't
+really belong in ``requests`` proper. The minimum tested requests version is
+``2.1.0``. In reality, the toolbelt should work with ``2.0.1`` as well, but
+some idiosyncracies prevent effective or sane testing on that version.
%prep
-%setup -q -n %{short_name}-%{version}
+%setup -q -n requests-toolbelt-%{version}
+rm -rf requests_toolbelt.egg-info
%build
%python_build
%install
%python_install
+%python_expand %fdupes -s %{buildroot}%{$python_sitelib}
%check
%python_exec setup.py test
%files %{python_files}
-%defattr(-,root,root)
-%doc AUTHORS.rst HISTORY.rst README.rst LICENSE
+%defattr(-,root,root,-)
+%doc AUTHORS.rst HISTORY.rst LICENSE README.rst
%{python_sitelib}/*
%changelog
++++++ requests-toolbelt-0.7.0.tar.gz -> requests-toolbelt-0.8.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/HISTORY.rst new/requests-toolbelt-0.8.0/HISTORY.rst
--- old/requests-toolbelt-0.7.0/HISTORY.rst 2016-07-22 15:03:36.000000000 +0200
+++ new/requests-toolbelt-0.8.0/HISTORY.rst 2017-05-20 23:31:29.000000000 +0200
@@ -1,6 +1,47 @@
History
=======
+0.8.0 -- 2017-05-20
+-------------------
+
+More information about this release can be found on the `0.8.0 milestone`_.
+
+New Features
+~~~~~~~~~~~~
+
+- Add ``UserAgentBuilder`` to provide more control over generated User-Agent
+ strings.
+
+Fixed Bugs
+~~~~~~~~~~
+
+- Include ``_validate_certificate`` in the lits of picked attributes on the
+ ``AppEngineAdapter``.
+- Fix backwards incompatibility in ``get_encodings_from_content``
+
+.. _0.8.0 milestone:
+ https://github.com/sigmavirus24/requests-toolbelt/milestones/0.8.0
+
+0.7.1 -- 2017-02-13
+-------------------
+
+More information about this release can be found on the `0.7.1 milestone`_.
+
+Fixed Bugs
+~~~~~~~~~~
+
+- Fixed monkey-patching for the AppEngineAdapter.
+
+- Make it easier to disable certificate verification when monkey-patching
+ AppEngine.
+
+- Handle ``multipart/form-data`` bodies without a trailing ``CRLF``.
+
+
+.. links
+.. _0.7.1 milestone:
+ https://github.com/sigmavirus24/requests-toolbelt/milestone/9
+
0.7.0 -- 2016-07-21
-------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/PKG-INFO new/requests-toolbelt-0.8.0/PKG-INFO
--- old/requests-toolbelt-0.7.0/PKG-INFO 2016-07-22 15:25:53.000000000 +0200
+++ new/requests-toolbelt-0.8.0/PKG-INFO 2017-05-20 23:32:33.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: requests-toolbelt
-Version: 0.7.0
+Version: 0.8.0
Summary: A utility belt for advanced users of python-requests
Home-page: https://toolbelt.readthedocs.org
Author: Ian Cordasco, Cory Benfield
@@ -125,6 +125,47 @@
History
=======
+ 0.8.0 -- 2017-05-20
+ -------------------
+
+ More information about this release can be found on the `0.8.0 milestone`_.
+
+ New Features
+ ~~~~~~~~~~~~
+
+ - Add ``UserAgentBuilder`` to provide more control over generated User-Agent
+ strings.
+
+ Fixed Bugs
+ ~~~~~~~~~~
+
+ - Include ``_validate_certificate`` in the lits of picked attributes on the
+ ``AppEngineAdapter``.
+ - Fix backwards incompatibility in ``get_encodings_from_content``
+
+ .. _0.8.0 milestone:
+ https://github.com/sigmavirus24/requests-toolbelt/milestones/0.8.0
+
+ 0.7.1 -- 2017-02-13
+ -------------------
+
+ More information about this release can be found on the `0.7.1 milestone`_.
+
+ Fixed Bugs
+ ~~~~~~~~~~
+
+ - Fixed monkey-patching for the AppEngineAdapter.
+
+ - Make it easier to disable certificate verification when monkey-patching
+ AppEngine.
+
+ - Handle ``multipart/form-data`` bodies without a trailing ``CRLF``.
+
+
+ .. links
+ .. _0.7.1 milestone:
+ https://github.com/sigmavirus24/requests-toolbelt/milestone/9
+
0.7.0 -- 2016-07-21
-------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/docs/adapters.rst new/requests-toolbelt-0.8.0/docs/adapters.rst
--- old/requests-toolbelt-0.7.0/docs/adapters.rst 2016-07-22 14:03:42.000000000 +0200
+++ new/requests-toolbelt-0.8.0/docs/adapters.rst 2017-03-25 12:07:58.000000000 +0100
@@ -28,7 +28,7 @@
As of version 2.10.0, Requests will be capable of supporting Google's App
Engine platform. In order to use Requests on GAE, however, you will need a
-custome adapter found here as
+custom adapter found here as
:class:`~requests_toolbelt.adapters.appengine.AppEngineAdapter`. There are two
ways to take advantage of this support at the moment:
@@ -53,6 +53,27 @@
appengine.monkeypatch()
+.. _insecure_appengine:
+
+If you should need to disable certificate validation when monkeypatching (to
+force third-party libraries that use Requests to not validate certificates, if
+they do not provide API surface to do so, for example), you can disable it:
+
+ .. code-block:: python
+
+ from requests_toolbelt.adapters import appengine
+ appengine.monkeypatch(validate_certificate=False)
+
+ .. warning::
+
+ If ``validate_certificate`` is ``False``, the monkeypatched adapter
+ will *not* validate certificates. This effectively sets the
+ ``validate_certificate`` argument to urlfetch.Fetch() to ``False``. You
+ should avoid using this wherever possible. Details can be found in the
+ `documentation for urlfetch.Fetch()`_.
+
+ .. _documentation for urlfetch.Fetch(): https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api....
+
.. autoclass:: requests_toolbelt.adapters.appengine.AppEngineAdapter
FingerprintAdapter
@@ -131,7 +152,7 @@
.. versionadded:: 0.3.0
-The :class:`~requests_toolbelt.adapters.source.SourceAddressAdapter` allows a
+The :class:`~requests_toolbelt.adapters.source.SourceAddressAdapter` allows a
user to specify a source address for their connnection.
.. autoclass:: requests_toolbelt.adapters.source.SourceAddressAdapter
@@ -206,7 +227,7 @@
.. code-block:: python
import requests
- from requests_toolbelt.adapter.socket_options import TCPKeepAliveAdapter
+ from requests_toolbelt.adapters.socket_options import TCPKeepAliveAdapter
session = requests.Session()
keep_alive = TCPKeepAliveAdapter(idle=120, count=20, interval=30)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/docs/user-agent.rst new/requests-toolbelt-0.8.0/docs/user-agent.rst
--- old/requests-toolbelt-0.7.0/docs/user-agent.rst 2015-10-31 22:20:13.000000000 +0100
+++ new/requests-toolbelt-0.8.0/docs/user-agent.rst 2017-05-20 23:20:06.000000000 +0200
@@ -43,7 +43,7 @@
import requests
import requests_toolbelt
- from requests_toolbelt.utils.user_agent import user_agent as ua
+ from requests_toolbelt.utils import user_agent as ua
user_agent = ua.user_agent('mypackage', '0.0.1',
extras=[('requests', requests.__version__),
@@ -56,3 +56,39 @@
Your user agent will now look like::
mypackage/0.0.1 requests/2.7.0 requests-toolbelt/0.5.0 CPython/2.7.10 Darwin/13.0.0
+
+Selecting Only What You Want
+----------------------------
+
+.. versionadded:: 0.8.0
+
+While most people will find the ``user_agent`` function sufficient for their
+usage, others will want to control exactly what information is included in the
+User-Agent. For those people, the
+:class:`~requests_toolbelt.utils.user_agent.UserAgentBuilder` is the correct
+tool. This is the tool that the toolbelt uses inside of
+:func:`~requests_toolbelt.utils.user_agent.user_agent`. For example, let's say
+you *only* want your package, its versions, and some extra information, in
+that case you would do:
+
+.. code-block:: python
+
+ import requests
+ from requests_toolbelt.utils import user_agent as ua
+
+ s = requests.Session()
+ s.headers['User-Agent'] = ua.UserAgentBuilder(
+ 'mypackage', '0.0.1',
+ ).include_extras([
+ ('requests', requests.__version__),
+ ]).build()
+
+Your user agent will now look like::
+
+ mypackage/0.0.1 requests/2.7.0
+
+You can also optionally include the Python version information and System
+information the same way that our ``user_agent`` function does.
+
+.. autoclass:: requests_toolbelt.utils.user_agent.UserAgentBuilder
+ :members:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt/__init__.py new/requests-toolbelt-0.8.0/requests_toolbelt/__init__.py
--- old/requests-toolbelt-0.7.0/requests_toolbelt/__init__.py 2016-07-22 15:03:52.000000000 +0200
+++ new/requests-toolbelt-0.8.0/requests_toolbelt/__init__.py 2017-05-20 23:20:06.000000000 +0200
@@ -22,7 +22,7 @@
__authors__ = 'Ian Cordasco, Cory Benfield'
__license__ = 'Apache v2.0'
__copyright__ = 'Copyright 2014 Ian Cordasco, Cory Benfield'
-__version__ = '0.7.0'
+__version__ = '0.8.0'
__version_info__ = tuple(int(i) for i in __version__.split('.'))
__all__ = [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt/adapters/appengine.py new/requests-toolbelt-0.8.0/requests_toolbelt/adapters/appengine.py
--- old/requests-toolbelt-0.7.0/requests_toolbelt/adapters/appengine.py 2016-07-22 02:26:26.000000000 +0200
+++ new/requests-toolbelt-0.8.0/requests_toolbelt/adapters/appengine.py 2017-03-25 12:07:58.000000000 +0100
@@ -29,8 +29,12 @@
>>> appengine.monkeypatch()
which will ensure all requests.Session objects use AppEngineAdapter properly.
+
+You are also able to :ref:`disable certificate validation `
+when monkey-patching.
"""
import requests
+import warnings
from requests import adapters
from requests import sessions
@@ -39,7 +43,24 @@
from .._compat import timeout
-class AppEngineAdapter(adapters.HTTPAdapter):
+class AppEngineMROHack(adapters.HTTPAdapter):
+ """Resolves infinite recursion when monkeypatching.
+
+ This works by injecting itself as the base class of both the
+ :class:`AppEngineAdapter` and Requests' default HTTPAdapter, which needs to
+ be done because default HTTPAdapter's MRO is recompiled when we
+ monkeypatch, at which point this class becomes HTTPAdapter's base class.
+ In addition, we use an instantiation flag to avoid infinite recursion.
+ """
+ _initialized = False
+
+ def __init__(self, *args, **kwargs):
+ if not self._initialized:
+ self._initialized = True
+ super(AppEngineMROHack, self).__init__(*args, **kwargs)
+
+
+class AppEngineAdapter(AppEngineMROHack, adapters.HTTPAdapter):
"""The transport adapter for Requests to use urllib3's GAE support.
Implements Requests's HTTPAdapter API.
@@ -50,6 +71,8 @@
for Requests to be able to use it.
"""
+ __attrs__ = adapters.HTTPAdapter.__attrs__ + ['_validate_certificate']
+
def __init__(self, validate_certificate=True, *args, **kwargs):
_check_version()
self._validate_certificate = validate_certificate
@@ -59,6 +82,32 @@
self.poolmanager = _AppEnginePoolManager(self._validate_certificate)
+class InsecureAppEngineAdapter(AppEngineAdapter):
+ """An always-insecure GAE adapter for Requests.
+
+ This is a variant of the the transport adapter for Requests to use
+ urllib3's GAE support that does not validate certificates. Use with
+ caution!
+
+ .. note::
+ The ``validate_certificate`` keyword argument will not be honored here
+ and is not part of the signature because we always force it to
+ ``False``.
+
+ See :class:`AppEngineAdapter` for further details.
+ """
+
+ def __init__(self, *args, **kwargs):
+ if kwargs.pop("validate_certificate", False):
+ warnings.warn("Certificate validation cannot be specified on the "
+ "InsecureAppEngineAdapter, but was present. This "
+ "will be ignored and certificate validation will "
+ "remain off.", exc.IgnoringGAECertificateValidation)
+
+ super(InsecureAppEngineAdapter, self).__init__(
+ validate_certificate=False, *args, **kwargs)
+
+
class _AppEnginePoolManager(object):
"""Implements urllib3's PoolManager API expected by requests.
@@ -123,18 +172,28 @@
**response_kw)
-def monkeypatch():
+def monkeypatch(validate_certificate=True):
"""Sets up all Sessions to use AppEngineAdapter by default.
If you don't want to deal with configuring your own Sessions,
or if you use libraries that use requests directly (ie requests.post),
then you may prefer to monkeypatch and auto-configure all Sessions.
+
+ .. warning: :
+
+ If ``validate_certificate`` is ``False``, certification validation will
+ effectively be disabled for all requests.
"""
_check_version()
# HACK: We should consider modifying urllib3 to support this cleanly,
# so that we can set a module-level variable in the sessions module,
# instead of overriding an imported HTTPAdapter as is done here.
- sessions.HTTPAdapter = AppEngineAdapter
+ adapter = AppEngineAdapter
+ if not validate_certificate:
+ adapter = InsecureAppEngineAdapter
+
+ sessions.HTTPAdapter = adapter
+ adapters.HTTPAdapter = adapter
def _check_version():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt/exceptions.py new/requests-toolbelt-0.8.0/requests_toolbelt/exceptions.py
--- old/requests-toolbelt-0.7.0/requests_toolbelt/exceptions.py 2016-07-22 14:33:56.000000000 +0200
+++ new/requests-toolbelt-0.8.0/requests_toolbelt/exceptions.py 2017-01-19 15:23:03.000000000 +0100
@@ -17,9 +17,21 @@
class RequestsVersionTooOld(Warning):
- """Used to indiciate that the Requests version is too old.
+ """Used to indicate that the Requests version is too old.
If the version of Requests is too old to support a feature, we will issue
this warning to the user.
"""
pass
+
+
+class IgnoringGAECertificateValidation(Warning):
+ """Used to indicate that given GAE validation behavior will be ignored.
+
+ If the user has tried to specify certificate validation when using the
+ insecure AppEngine adapter, it will be ignored (certificate validation will
+ remain off), so we will issue this warning to the user.
+
+ In :class:`requests_toolbelt.adapters.appengine.InsecureAppEngineAdapter`.
+ """
+ pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt/multipart/decoder.py new/requests-toolbelt-0.8.0/requests_toolbelt/multipart/decoder.py
--- old/requests-toolbelt-0.7.0/requests_toolbelt/multipart/decoder.py 2014-04-12 23:48:38.000000000 +0200
+++ new/requests-toolbelt-0.8.0/requests_toolbelt/multipart/decoder.py 2017-02-10 22:55:25.000000000 +0100
@@ -143,7 +143,10 @@
return BodyPart(fixed, self.encoding)
def test_part(part):
- return part != b'' and part != b'\r\n' and part[:4] != b'--\r\n'
+ return (part != b'' and
+ part != b'\r\n' and
+ part[:4] != b'--\r\n' and
+ part != b'--')
parts = self.content.split(b''.join((b'\r\n', boundary)))
self.parts = tuple(body_part(x) for x in parts if test_part(x))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt/utils/deprecated.py new/requests-toolbelt-0.8.0/requests_toolbelt/utils/deprecated.py
--- old/requests-toolbelt-0.7.0/requests_toolbelt/utils/deprecated.py 2015-03-29 06:12:14.000000000 +0200
+++ new/requests-toolbelt-0.8.0/requests_toolbelt/utils/deprecated.py 2017-03-25 12:07:58.000000000 +0100
@@ -1,9 +1,22 @@
# -*- coding: utf-8 -*-
"""A collection of functions deprecated in requests.utils."""
import re
+import sys
from requests import utils
+find_charset = re.compile(
+ br']', flags=re.I
+).findall
+
+find_pragma = re.compile(
+ br']', flags=re.I
+).findall
+
+find_xml = re.compile(
+ br'^<\?xml.*?encoding=["\']*(.+?)["\'>]'
+).findall
+
def get_encodings_from_content(content):
"""Return encodings from given content string.
@@ -16,22 +29,16 @@
r = requests.get(url)
encodings = deprecated.get_encodings_from_content(r)
- :param content: bytestring to extract encodings from.
+ :param content: bytestring to extract encodings from
:type content: bytes
+ :return: encodings detected in the provided content
+ :rtype: list(str)
"""
- find_charset = re.compile(
- r']', flags=re.I
- ).findall
-
- find_pragma = re.compile(
- r']', flags=re.I
- ).findall
-
- find_xml = re.compile(
- r'^<\?xml.*?encoding=["\']*(.+?)["\'>]'
- ).findall
-
- return find_charset(content) + find_pragma(content) + find_xml(content)
+ encodings = (find_charset(content) + find_pragma(content)
+ + find_xml(content))
+ if (3, 0) <= sys.version_info < (4, 0):
+ encodings = [encoding.decode('utf8') for encoding in encodings]
+ return encodings
def get_unicode_from_response(response):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt/utils/user_agent.py new/requests-toolbelt-0.8.0/requests_toolbelt/utils/user_agent.py
--- old/requests-toolbelt-0.7.0/requests_toolbelt/utils/user_agent.py 2015-10-31 22:20:13.000000000 +0100
+++ new/requests-toolbelt-0.8.0/requests_toolbelt/utils/user_agent.py 2017-05-20 23:20:06.000000000 +0200
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
+import collections
import platform
import sys
def user_agent(name, version, extras=None):
- """
- Returns an internet-friendly user_agent string.
+ """Return an internet-friendly user_agent string.
The majority of this code has been wilfully stolen from the equivalent
function in Requests.
@@ -17,35 +17,88 @@
:returns: Formatted user-agent string
:rtype: str
"""
- try:
- p_system = platform.system()
- p_release = platform.release()
- except IOError:
- p_system = 'Unknown'
- p_release = 'Unknown'
-
if extras is None:
extras = []
- if any(len(extra) != 2 for extra in extras):
- raise ValueError('Extras should be a sequence of two item tuples.')
+ return UserAgentBuilder(
+ name, version
+ ).include_extras(
+ extras
+ ).include_implementation(
+ ).include_system().build()
+
+
+class UserAgentBuilder(object):
+ """Class to provide a greater level of control than :func:`user_agent`.
+
+ This is used by :func:`user_agent` to build its User-Agent string.
+
+ .. code-block:: python
+
+ user_agent_str = UserAgentBuilder(
+ name='requests-toolbelt',
+ version='17.4.0',
+ ).include_implementation(
+ ).include_system(
+ ).include_extras([
+ ('requests', '2.14.2'),
+ ('urllib3', '1.21.2'),
+ ]).build()
+
+ """
format_string = '%s/%s'
- extra_pieces = [
- format_string % (extra_name, extra_version)
- for extra_name, extra_version in extras
- ]
-
- user_agent_pieces = ([format_string % (name, version)] + extra_pieces +
- [_implementation_string(),
- '%s/%s' % (p_system, p_release)])
+ def __init__(self, name, version):
+ """Initialize our builder with the name and version of our user agent.
- return " ".join(user_agent_pieces)
+ :param str name:
+ Name of our user-agent.
+ :param str version:
+ The version string for user-agent.
+ """
+ self._pieces = collections.deque([(name, version)])
+
+ def build(self):
+ """Finalize the User-Agent string.
+
+ :returns:
+ Formatted User-Agent string.
+ :rtype:
+ str
+ """
+ return " ".join([self.format_string % piece for piece in self._pieces])
+
+ def include_extras(self, extras):
+ """Include extra portions of the User-Agent.
+
+ :param list extras:
+ list of tuples of extra-name and extra-version
+ """
+ if any(len(extra) != 2 for extra in extras):
+ raise ValueError('Extras should be a sequence of two item tuples.')
+
+ self._pieces.extend(extras)
+ return self
+
+ def include_implementation(self):
+ """Append the implementation string to the user-agent string.
+
+ This adds the the information that you're using CPython 2.7.13 to the
+ User-Agent.
+ """
+ self._pieces.append(_implementation_tuple())
+ return self
+
+ def include_system(self):
+ """Append the information about the Operating System."""
+ self._pieces.append(_platform_tuple())
+ return self
-def _implementation_string():
- """
+def _implementation_tuple():
+ """Return the tuple of interpreter name and version.
+
Returns a string that provides both the name and the version of the Python
implementation currently running. For example, on CPython 2.7.5 it will
return "CPython/2.7.5".
@@ -73,4 +126,18 @@
else:
implementation_version = 'Unknown'
- return "%s/%s" % (implementation, implementation_version)
+ return (implementation, implementation_version)
+
+
+def _implementation_string():
+ return "%s/%s" % _implementation_tuple()
+
+
+def _platform_tuple():
+ try:
+ p_system = platform.system()
+ p_release = platform.release()
+ except IOError:
+ p_system = 'Unknown'
+ p_release = 'Unknown'
+ return (p_system, p_release)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/requests_toolbelt.egg-info/PKG-INFO new/requests-toolbelt-0.8.0/requests_toolbelt.egg-info/PKG-INFO
--- old/requests-toolbelt-0.7.0/requests_toolbelt.egg-info/PKG-INFO 2016-07-22 15:25:52.000000000 +0200
+++ new/requests-toolbelt-0.8.0/requests_toolbelt.egg-info/PKG-INFO 2017-05-20 23:32:32.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: requests-toolbelt
-Version: 0.7.0
+Version: 0.8.0
Summary: A utility belt for advanced users of python-requests
Home-page: https://toolbelt.readthedocs.org
Author: Ian Cordasco, Cory Benfield
@@ -125,6 +125,47 @@
History
=======
+ 0.8.0 -- 2017-05-20
+ -------------------
+
+ More information about this release can be found on the `0.8.0 milestone`_.
+
+ New Features
+ ~~~~~~~~~~~~
+
+ - Add ``UserAgentBuilder`` to provide more control over generated User-Agent
+ strings.
+
+ Fixed Bugs
+ ~~~~~~~~~~
+
+ - Include ``_validate_certificate`` in the lits of picked attributes on the
+ ``AppEngineAdapter``.
+ - Fix backwards incompatibility in ``get_encodings_from_content``
+
+ .. _0.8.0 milestone:
+ https://github.com/sigmavirus24/requests-toolbelt/milestones/0.8.0
+
+ 0.7.1 -- 2017-02-13
+ -------------------
+
+ More information about this release can be found on the `0.7.1 milestone`_.
+
+ Fixed Bugs
+ ~~~~~~~~~~
+
+ - Fixed monkey-patching for the AppEngineAdapter.
+
+ - Make it easier to disable certificate verification when monkey-patching
+ AppEngine.
+
+ - Handle ``multipart/form-data`` bodies without a trailing ``CRLF``.
+
+
+ .. links
+ .. _0.7.1 milestone:
+ https://github.com/sigmavirus24/requests-toolbelt/milestone/9
+
0.7.0 -- 2016-07-21
-------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/setup.cfg new/requests-toolbelt-0.8.0/setup.cfg
--- old/requests-toolbelt-0.7.0/setup.cfg 2016-07-22 15:25:53.000000000 +0200
+++ new/requests-toolbelt-0.8.0/setup.cfg 2017-05-20 23:32:33.000000000 +0200
@@ -4,5 +4,4 @@
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/tests/test_appengine_adapter.py new/requests-toolbelt-0.8.0/tests/test_appengine_adapter.py
--- old/requests-toolbelt-0.7.0/tests/test_appengine_adapter.py 2016-05-10 15:18:59.000000000 +0200
+++ new/requests-toolbelt-0.8.0/tests/test_appengine_adapter.py 2017-01-19 15:23:03.000000000 +0100
@@ -6,6 +6,8 @@
import pytest
import requests
+from requests_toolbelt import exceptions as exc
+
REQUESTS_SUPPORTS_GAE = requests.__build__ >= 0x021000
if REQUESTS_SUPPORTS_GAE:
@@ -42,3 +44,46 @@
assert args == ('http://url/',)
assert kwargs['deadline'] == 9
assert kwargs['headers']['Foo'] == 'bar'
+
+
+@pytest.mark.skipif(sys.version_info >= (3,),
+ reason="App Engine doesn't support Python 3 (yet) and "
+ "urllib3's appengine contrib code is Python 2 "
+ "only. Until the latter changes, this test will "
+ "be skipped, unfortunately.")
+@pytest.mark.skipif(not REQUESTS_SUPPORTS_GAE,
+ reason="Requires Requests v2.10.0 or later")
+def test_appengine_monkeypatch():
+ """Tests monkeypatching Requests adapters for AppEngine compatibility.
+ """
+ adapter = requests.sessions.HTTPAdapter
+
+ appengine.monkeypatch()
+
+ assert requests.sessions.HTTPAdapter == appengine.AppEngineAdapter
+ assert requests.adapters.HTTPAdapter == appengine.AppEngineAdapter
+
+ appengine.monkeypatch(validate_certificate=False)
+
+ assert requests.sessions.HTTPAdapter == appengine.InsecureAppEngineAdapter
+ assert requests.adapters.HTTPAdapter == appengine.InsecureAppEngineAdapter
+
+ requests.sessions.HTTPAdapter = adapter
+ requests.adapters.HTTPAdapter = adapter
+
+
+@pytest.mark.skipif(sys.version_info >= (3,),
+ reason="App Engine doesn't support Python 3 (yet) and "
+ "urllib3's appengine contrib code is Python 2 "
+ "only. Until the latter changes, this test will "
+ "be skipped, unfortunately.")
+@pytest.mark.skipif(not REQUESTS_SUPPORTS_GAE,
+ reason="Requires Requests v2.10.0 or later")
+@mock.patch.object(urllib3_appeng, 'urlfetch')
+def test_insecure_appengine_adapter(mock_urlfetch):
+ adapter = appengine.InsecureAppEngineAdapter()
+
+ assert not adapter._validate_certificate
+
+ with pytest.warns(exc.IgnoringGAECertificateValidation):
+ adapter = appengine.InsecureAppEngineAdapter(validate_certificate=True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/tests/test_user_agent.py new/requests-toolbelt-0.8.0/tests/test_user_agent.py
--- old/requests-toolbelt-0.7.0/tests/test_user_agent.py 2015-10-31 22:20:13.000000000 +0100
+++ new/requests-toolbelt-0.8.0/tests/test_user_agent.py 2017-05-20 23:20:06.000000000 +0200
@@ -15,6 +15,35 @@
pass
+class TestUserAgentBuilder(unittest.TestCase):
+ def test_only_user_agent_name(self):
+ assert 'fake/1.0.0' == ua.UserAgentBuilder('fake', '1.0.0').build()
+
+ def test_includes_extras(self):
+ expected = 'fake/1.0.0 another-fake/2.0.1 yet-another-fake/17.1.0'
+ actual = ua.UserAgentBuilder('fake', '1.0.0').include_extras([
+ ('another-fake', '2.0.1'),
+ ('yet-another-fake', '17.1.0'),
+ ]).build()
+ assert expected == actual
+
+ @patch('platform.python_implementation', return_value='CPython')
+ @patch('platform.python_version', return_value='2.7.13')
+ def test_include_implementation(self, *_):
+ expected = 'fake/1.0.0 CPython/2.7.13'
+ actual = ua.UserAgentBuilder('fake', '1.0.0').include_implementation(
+ ).build()
+ assert expected == actual
+
+ @patch('platform.system', return_value='Linux')
+ @patch('platform.release', return_value='4.9.5')
+ def test_include_system(self, *_):
+ expected = 'fake/1.0.0 Linux/4.9.5'
+ actual = ua.UserAgentBuilder('fake', '1.0.0').include_system(
+ ).build()
+ assert expected == actual
+
+
class TestUserAgent(unittest.TestCase):
def test_user_agent_provides_package_name(self):
assert "my-package" in ua.user_agent("my-package", "0.0.1")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/requests-toolbelt-0.7.0/tox.ini new/requests-toolbelt-0.8.0/tox.ini
--- old/requests-toolbelt-0.7.0/tox.ini 2016-07-22 15:25:35.000000000 +0200
+++ new/requests-toolbelt-0.8.0/tox.ini 2017-01-19 15:23:03.000000000 +0100
@@ -44,7 +44,7 @@
[testenv:release]
deps =
- twine >= 1.5.0
+ twine >= 1.4.0
wheel
commands =
python setup.py sdist bdist_wheel