[Python-modules-commits] [python-treq] 01/03: impor treq 15.1.0
Orestis Ioannou
oorestisime-guest at moszumanska.debian.org
Tue Apr 26 20:56:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
oorestisime-guest pushed a commit to branch master
in repository python-treq.
commit b849ce523d00693b21c151871234fe330498e4fc
Author: Orestis Ioannou <orestis at oioannou.com>
Date: Sat Apr 23 00:13:45 2016 +0200
impor treq 15.1.0
---
LICENSE | 21 ++
MANIFEST.in | 6 +
PKG-INFO | 102 ++++++
README.rst | 80 +++++
docs/Makefile | 153 +++++++++
docs/_static/.keepme | 0
docs/api.rst | 84 +++++
docs/conf.py | 243 +++++++++++++
docs/examples/_utils.py | 10 +
docs/examples/basic_auth.py | 15 +
docs/examples/basic_get.py | 12 +
docs/examples/basic_post.py | 16 +
docs/examples/disable_redirects.py | 12 +
docs/examples/download_file.py | 13 +
docs/examples/query_params.py | 39 +++
docs/examples/redirects.py | 12 +
docs/examples/response_history.py | 17 +
docs/examples/using_cookies.py | 22 ++
docs/howto.rst | 117 +++++++
docs/index.rst | 116 +++++++
docs/make.bat | 190 +++++++++++
requirements-dev.txt | 5 +
setup.cfg | 17 +
setup.py | 57 ++++
tox.ini | 44 +++
tox2travis.py | 57 ++++
treq.egg-info/PKG-INFO | 102 ++++++
treq.egg-info/SOURCES.txt | 52 +++
treq.egg-info/dependency_links.txt | 1 +
treq.egg-info/pbr.json | 1 +
treq.egg-info/requires.txt | 5 +
treq.egg-info/top_level.txt | 1 +
treq/__init__.py | 11 +
treq/_utils.py | 47 +++
treq/_version | 1 +
treq/api.py | 118 +++++++
treq/auth.py | 41 +++
treq/client.py | 328 ++++++++++++++++++
treq/content.py | 132 +++++++
treq/multipart.py | 358 +++++++++++++++++++
treq/response.py | 48 +++
treq/test/__init__.py | 0
treq/test/test_api.py | 55 +++
treq/test/test_auth.py | 75 ++++
treq/test/test_client.py | 453 +++++++++++++++++++++++++
treq/test/test_content.py | 159 +++++++++
treq/test/test_multipart.py | 679 +++++++++++++++++++++++++++++++++++++
treq/test/test_response.py | 64 ++++
treq/test/test_testing.py | 457 +++++++++++++++++++++++++
treq/test/test_treq_integration.py | 268 +++++++++++++++
treq/test/test_utils.py | 77 +++++
treq/test/util.py | 47 +++
treq/testing.py | 440 ++++++++++++++++++++++++
53 files changed, 5480 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bfdfa98
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+This is the MIT license.
+
+Copyright (c) 2012-2014 David Reid
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..7feb963
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,6 @@
+include treq/_version README.rst LICENSE tox.ini tox2travis.py requirements-dev.txt
+recursive-include docs *
+prune docs/_build
+exclude .travis.yml
+
+global-exclude .DS_Store *.pyc
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..3ebd400
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,102 @@
+Metadata-Version: 1.1
+Name: treq
+Version: 15.1.0
+Summary: A requests-like API built on top of twisted.web's Agent
+Home-page: http://github.com/twisted/treq
+Author: Amber Brown
+Author-email: hawkowl at twistedmatrix.com
+License: MIT/X
+Description: treq
+ ====
+
+ |pypi|_
+ |build|_
+ |coverage|_
+
+ ``treq`` is an HTTP library inspired by
+ `requests <http://www.python-requests.org>`_ but written on top of
+ `Twisted <http://www.twistedmatrix.com>`_'s
+ `Agents <http://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html>`_.
+
+ It provides a simple, higher level API for making HTTP requests when
+ using Twisted.
+
+ .. code-block:: python
+
+ >>> from treq import get
+
+ >>> def done(response):
+ ... print response.code
+ ... reactor.stop()
+
+ >>> get("http://www.github.com").addCallback(done)
+
+ >>> from twisted.internet import reactor
+ >>> reactor.run()
+ 200
+
+ For more info `read the docs <http://treq.readthedocs.org>`_.
+
+ Contribute
+ ==========
+
+ ``treq`` is hosted on `GitHub <http://github.com/twisted/treq>`_.
+
+ Feel free to fork and send contributions over.
+
+ Developing
+ ==========
+
+ Install dependencies:
+
+ ::
+
+ pip install -r requirements-dev.txt
+
+ Optionally install PyOpenSSL:
+
+ ::
+
+ pip install PyOpenSSL
+
+ Run Tests (unit & integration):
+
+ ::
+
+ trial treq
+
+ Lint:
+
+ ::
+
+ pep8 treq
+ pyflakes treq
+
+ Build docs:
+
+ ::
+
+ cd docs; make html
+
+ .. |build| image:: https://secure.travis-ci.org/twisted/treq.svg?branch=master
+ .. _build: http://travis-ci.org/twisted/treq
+
+ .. |coverage| image:: https://codecov.io/github/twisted/treq/coverage.svg?branch=master
+ .. _coverage: https://codecov.io/github/twisted/treq
+
+ .. |pypi| image:: http://img.shields.io/pypi/v/treq.svg
+ .. _pypi: https://pypi.python.org/pypi/treq
+
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Framework :: Twisted
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..166fbc3
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,80 @@
+treq
+====
+
+|pypi|_
+|build|_
+|coverage|_
+
+``treq`` is an HTTP library inspired by
+`requests <http://www.python-requests.org>`_ but written on top of
+`Twisted <http://www.twistedmatrix.com>`_'s
+`Agents <http://twistedmatrix.com/documents/current/api/twisted.web.client.Agent.html>`_.
+
+It provides a simple, higher level API for making HTTP requests when
+using Twisted.
+
+.. code-block:: python
+
+ >>> from treq import get
+
+ >>> def done(response):
+ ... print response.code
+ ... reactor.stop()
+
+ >>> get("http://www.github.com").addCallback(done)
+
+ >>> from twisted.internet import reactor
+ >>> reactor.run()
+ 200
+
+For more info `read the docs <http://treq.readthedocs.org>`_.
+
+Contribute
+==========
+
+``treq`` is hosted on `GitHub <http://github.com/twisted/treq>`_.
+
+Feel free to fork and send contributions over.
+
+Developing
+==========
+
+Install dependencies:
+
+::
+
+ pip install -r requirements-dev.txt
+
+Optionally install PyOpenSSL:
+
+::
+
+ pip install PyOpenSSL
+
+Run Tests (unit & integration):
+
+::
+
+ trial treq
+
+Lint:
+
+::
+
+ pep8 treq
+ pyflakes treq
+
+Build docs:
+
+::
+
+ cd docs; make html
+
+.. |build| image:: https://secure.travis-ci.org/twisted/treq.svg?branch=master
+.. _build: http://travis-ci.org/twisted/treq
+
+.. |coverage| image:: https://codecov.io/github/twisted/treq/coverage.svg?branch=master
+.. _coverage: https://codecov.io/github/twisted/treq
+
+.. |pypi| image:: http://img.shields.io/pypi/v/treq.svg
+.. _pypi: https://pypi.python.org/pypi/treq
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..7dd572c
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/treq.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/treq.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/treq"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/treq"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/_static/.keepme b/docs/_static/.keepme
new file mode 100644
index 0000000..e69de29
diff --git a/docs/api.rst b/docs/api.rst
new file mode 100644
index 0000000..31f8f94
--- /dev/null
+++ b/docs/api.rst
@@ -0,0 +1,84 @@
+Making Requests
+===============
+
+.. module:: treq
+
+.. autofunction:: request
+.. autofunction:: get
+.. autofunction:: head
+.. autofunction:: post
+.. autofunction:: put
+.. autofunction:: patch
+.. autofunction:: delete
+
+Accessing Content
+=================
+
+.. autofunction:: collect
+.. autofunction:: content
+.. autofunction:: text_content
+.. autofunction:: json_content
+
+Responses
+=========
+
+.. module:: treq.response
+
+.. class:: Response
+
+ .. method:: collect(collector)
+
+ Incrementally collect the body of the response.
+
+ :param collector: A single argument callable that will be called
+ with chunks of body data as it is received.
+
+ :returns: A `Deferred` that fires when the entire body has been
+ received.
+
+ .. method:: content()
+
+ Read the entire body all at once.
+
+ :returns: A `Deferred` that fires with a `bytes` object when the entire
+ body has been received.
+
+ .. method:: text(encoding='ISO-8859-1')
+
+ Read the entire body all at once as text.
+ :param encoding: An encoding for the body, if none is given the
+ encoding will be guessed, defaulting to this argument.
+
+ :returns: A `Deferred` that fires with a `unicode` object when the
+ entire body has been received.
+
+ .. method:: json()
+
+ Read the entire body all at once and decode it as JSON.
+
+ :returns: A `Deferred` that fires with the result of `json.loads` on
+ the body after it has been received.
+
+ .. method:: history()
+
+ Get a list of all responses that (such as intermediate redirects),
+ that ultimately ended in the current response.
+
+ :returns: A `list` of :class:`treq.response.Response` objects.
+
+ .. method:: cookies()
+
+ :returns: A `CookieJar`.
+
+ Inherited from twisted.web.iweb.IResponse.
+
+ .. attribute:: version
+ .. attribute:: code
+ .. attribute:: phrase
+ .. attribute:: headers
+ .. attribute:: length
+ .. attribute:: request
+ .. attribute:: previousResponse
+
+ .. method:: deliverBody(protocol)
+ .. method:: setPreviousResponse(response)
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..c36efd2
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,243 @@
+# -*- coding: utf-8 -*-
+#
+# treq documentation build configuration file, created by
+# sphinx-quickstart on Mon Dec 10 22:32:11 2012.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('..'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.viewcode', 'sphinx.ext.autodoc']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'treq'
+copyright = u'2014, David Reid'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The full version, including alpha/beta/rc tags.
+release = open('../treq/_version').readline().strip()
+version = '.'.join(release.split('.')[:2])
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'treqdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'treq.tex', u'treq Documentation',
+ u'David Reid', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'treq', u'treq Documentation',
+ [u'David Reid'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'treq', u'treq Documentation',
+ u'David Reid', 'treq', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+RTD_NEW_THEME = True
diff --git a/docs/examples/_utils.py b/docs/examples/_utils.py
new file mode 100644
index 0000000..2ac316a
--- /dev/null
+++ b/docs/examples/_utils.py
@@ -0,0 +1,10 @@
+from __future__ import print_function
+
+import treq
+
+
+def print_response(response):
+ print(response.code, response.phrase)
+ print(response.headers)
+
+ return treq.text_content(response).addCallback(print)
diff --git a/docs/examples/basic_auth.py b/docs/examples/basic_auth.py
new file mode 100644
index 0000000..73a9918
--- /dev/null
+++ b/docs/examples/basic_auth.py
@@ -0,0 +1,15 @@
+from twisted.internet.task import react
+from _utils import print_response
+
+import treq
+
+
+def main(reactor, *args):
+ d = treq.get(
+ 'http://httpbin.org/basic-auth/treq/treq',
+ auth=('treq', 'treq')
+ )
+ d.addCallback(print_response)
+ return d
+
+react(main, [])
diff --git a/docs/examples/basic_get.py b/docs/examples/basic_get.py
new file mode 100644
index 0000000..c92c821
--- /dev/null
+++ b/docs/examples/basic_get.py
@@ -0,0 +1,12 @@
+from twisted.internet.task import react
+from _utils import print_response
+
+import treq
+
+
+def main(reactor, *args):
+ d = treq.get('http://httpbin.org/get')
+ d.addCallback(print_response)
+ return d
+
+react(main, [])
diff --git a/docs/examples/basic_post.py b/docs/examples/basic_post.py
new file mode 100644
index 0000000..dfc9477
--- /dev/null
+++ b/docs/examples/basic_post.py
@@ -0,0 +1,16 @@
+import json
+
+from twisted.internet.task import react
+from _utils import print_response
+
+import treq
+
+
+def main(reactor, *args):
+ d = treq.post('http://httpbin.org/post',
+ json.dumps({"msg": "Hello!"}),
+ headers={'Content-Type': ['application/json']})
+ d.addCallback(print_response)
+ return d
+
+react(main, [])
diff --git a/docs/examples/disable_redirects.py b/docs/examples/disable_redirects.py
new file mode 100644
index 0000000..dac64e0
--- /dev/null
+++ b/docs/examples/disable_redirects.py
@@ -0,0 +1,12 @@
+from twisted.internet.task import react
+from _utils import print_response
+
+import treq
+
+
+def main(reactor, *args):
+ d = treq.get('http://httpbin.org/redirect/1', allow_redirects=False)
+ d.addCallback(print_response)
+ return d
+
+react(main, [])
diff --git a/docs/examples/download_file.py b/docs/examples/download_file.py
new file mode 100644
index 0000000..66d7c4c
--- /dev/null
+++ b/docs/examples/download_file.py
@@ -0,0 +1,13 @@
+from twisted.internet.task import react
+
+import treq
+
+
+def download_file(reactor, url, destination_filename):
+ destination = file(destination_filename, 'w')
+ d = treq.get(url)
+ d.addCallback(treq.collect, destination.write)
+ d.addBoth(lambda _: destination.close())
+ return d
+
+react(download_file, ['http://httpbin.org/get', 'download.txt'])
diff --git a/docs/examples/query_params.py b/docs/examples/query_params.py
new file mode 100644
index 0000000..2d56a39
--- /dev/null
+++ b/docs/examples/query_params.py
@@ -0,0 +1,39 @@
+from twisted.internet.task import react
+from twisted.internet.defer import inlineCallbacks
+
+import treq
+
+
+ at inlineCallbacks
+def main(reactor):
+ print 'List of tuples'
+ resp = yield treq.get('http://httpbin.org/get',
+ params=[('foo', 'bar'), ('baz', 'bax')])
+ content = yield treq.content(resp)
+ print content
+
+ print 'Single value dictionary'
+ resp = yield treq.get('http://httpbin.org/get',
+ params={'foo': 'bar', 'baz': 'bax'})
+ content = yield treq.content(resp)
+ print content
+
+ print 'Multi value dictionary'
+ resp = yield treq.get('http://httpbin.org/get',
+ params={'foo': ['bar', 'baz', 'bax']})
+ content = yield treq.content(resp)
+ print content
+
+ print 'Mixed value dictionary'
+ resp = yield treq.get('http://httpbin.org/get',
+ params={'foo': ['bar', 'baz'], 'bax': 'quux'})
+ content = yield treq.content(resp)
+ print content
+
+ print 'Preserved query parameters'
+ resp = yield treq.get('http://httpbin.org/get?foo=bar',
+ params={'baz': 'bax'})
+ content = yield treq.content(resp)
+ print content
+
+react(main, [])
diff --git a/docs/examples/redirects.py b/docs/examples/redirects.py
new file mode 100644
index 0000000..a9a6660
--- /dev/null
+++ b/docs/examples/redirects.py
@@ -0,0 +1,12 @@
+from twisted.internet.task import react
+from _utils import print_response
+
+import treq
+
+
+def main(reactor, *args):
+ d = treq.get('http://httpbin.org/redirect/1')
+ d.addCallback(print_response)
+ return d
+
+react(main, [])
diff --git a/docs/examples/response_history.py b/docs/examples/response_history.py
new file mode 100644
index 0000000..61a2c16
--- /dev/null
+++ b/docs/examples/response_history.py
@@ -0,0 +1,17 @@
+from twisted.internet.task import react
+from _utils import print_response
+
+import treq
+
+
+def main(reactor, *args):
+ d = treq.get('http://httpbin.org/redirect/1')
+
+ def cb(response):
+ print 'Response history:', response.history()
+ return print_response(response)
+
+ d.addCallback(cb)
+ return d
+
+react(main, [])
diff --git a/docs/examples/using_cookies.py b/docs/examples/using_cookies.py
new file mode 100644
index 0000000..a963716
--- /dev/null
+++ b/docs/examples/using_cookies.py
... 4855 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-treq.git
More information about the Python-modules-commits
mailing list