[Python-modules-commits] [prawcore] 01/02: Import Upstream version 0.11.0
Josué Ortega
josue at moszumanska.debian.org
Tue Aug 8 21:41:27 UTC 2017
This is an automated email from the git hooks/post-receive script.
josue pushed a commit to branch master
in repository prawcore.
commit 6fd5e6ab3173560bfc16b88f89e2155f0c994f18
Author: Josue Ortega <josue at debian.org>
Date: Tue Aug 8 17:38:15 2017 -0400
Import Upstream version 0.11.0
---
AUTHORS.rst | 14 ++
CHANGES.rst | 276 +++++++++++++++++++++++++++
CODE_OF_CONDUCT.md | 74 ++++++++
LICENSE.txt | 22 +++
MANIFEST.in | 1 +
PKG-INFO | 116 ++++++++++++
README.rst | 92 +++++++++
prawcore.egg-info/PKG-INFO | 116 ++++++++++++
prawcore.egg-info/SOURCES.txt | 21 +++
prawcore.egg-info/dependency_links.txt | 1 +
prawcore.egg-info/requires.txt | 1 +
prawcore.egg-info/top_level.txt | 1 +
prawcore/__init__.py | 13 ++
prawcore/auth.py | 328 +++++++++++++++++++++++++++++++++
prawcore/const.py | 9 +
prawcore/exceptions.py | 122 ++++++++++++
prawcore/rate_limit.py | 80 ++++++++
prawcore/requestor.py | 49 +++++
prawcore/sessions.py | 184 ++++++++++++++++++
prawcore/util.py | 21 +++
setup.cfg | 7 +
setup.py | 48 +++++
22 files changed, 1596 insertions(+)
diff --git a/AUTHORS.rst b/AUTHORS.rst
new file mode 100644
index 0000000..a865f15
--- /dev/null
+++ b/AUTHORS.rst
@@ -0,0 +1,14 @@
+prawcore is written and maintained by Bryce Boe and various contributors:
+
+Maintainers
+===========
+
+- Bryce Boe <bbzbryce at gmail.com> `@bboe <https://github.com/bboe>`_
+
+
+Contributors
+============
+
+- nmtake `@nmtake <https://github.com/nmtake>`_
+- elnuno `@elnuno <https://github.com/elnuno>`_
+- Add "Name <email (optional)> and github profile link" above this line.
diff --git a/CHANGES.rst b/CHANGES.rst
new file mode 100644
index 0000000..eba6d09
--- /dev/null
+++ b/CHANGES.rst
@@ -0,0 +1,276 @@
+Change Log
+==========
+
+prawcore follows `semantic versioning <http://semver.org/>`_ with the exception
+that deprecations will not be announced by a minor release.
+
+0.11.0 (2017-05-27)
+-------------------
+
+**Added**
+
+* ``Conflict`` exception is raised when response status 409 is returned.
+
+0.10.1 (2017-04-10)
+-------------------
+
+**Fixed**
+
+* ``InvalidToken`` is again raised on 401 when a non-refreshable application is
+ in use.
+
+0.10.0 (2017-04-10)
+-------------------
+
+**Added**
+
+* ``ConnectionError`` exceptions are automatically retried. This handles
+ ``Connection Reset by Peer`` issues that appear to occur somewhat frequently
+ when running on Amazon EC2.
+
+**Changed**
+
+* Calling ``RateLimiter`` now requires a second positional argument,
+ ``set_header_callback``.
+* In the event a 401 unauthorized occurs, the access token is cleared and the
+ request is retried.
+
+**Fixed**
+
+* Check if the access token is expired immediately before every authorized
+ request, rather than just before the request flow. This new approach accounts
+ for failure retries, and rate limiter delay.
+
+0.9.0 (2017-03-11)
+------------------
+
+**Added**
+
+* Add ``session`` parameter to Requestor to ease support of custom sessions
+ (e.g. caching or mock ones).
+
+0.8.0 (2017-01-29)
+------------------
+
+**Added**
+
+* Handle 413 Request entity too large responses.
+* ``reset_timestamp`` to ``RateLimiter``.
+
+**Fixed**
+
+* Avoid modifying passed in ``data`` and ``params`` to ``Session.request``.
+
+0.7.0 (2017-01-16)
+------------------
+
+**Added**
+
+``ChunkedEncodingError`` is automatically retried like the server errors.
+
+0.6.0 (2016-12-24)
+------------------
+
+**Added**
+
+* Handle 500 responses.
+* Handle Cloudflair 520 responses.
+
+
+0.5.0 (2016-12-13)
+------------------
+
+**Added**
+
+All network requests now have a 16 second timeout by default. The environment
+variable ``prawcore_timeout`` can be used to adjust the value.
+
+0.4.0 (2016-12-09)
+------------------
+
+**Changed**
+
+* Prevent '(None)' from appearing in OAuthException message.
+
+0.3.0 (2016-11-20)
+------------------
+
+**Added**
+
+* Add ``files`` parameter to ``Session.request`` to support image upload
+ operations.
+* Add ``duration`` and ``implicit`` parameters to
+ ``UntrustedAuthenticator.authorization_url`` so that the method also supports
+ the code grant flow.
+
+**Fixed**
+
+* ``Authorizer`` class can be used with ``UntrustedAuthenticator``.
+
+0.2.1 (2016-08-07)
+------------------
+
+**Fixed**
+
+* ``session`` works with ``DeviceIDAuthorizer`` and ``ImplicitAuthorizer``.
+
+
+0.2.0 (2016-08-07)
+------------------
+
+**Added**
+
+* Add ``ImplicitAuthorizer``.
+
+**Changed**
+
+* Split ``Authenticator`` into ``TrustedAuthenticator`` and
+ ``UntrustedAuthenticator``.
+
+0.1.1 (2016-08-06)
+------------------
+
+**Added**
+
+* Add ``DeviceIDAuthorizer`` that permits installed application access to the
+ API.
+
+0.1.0 (2016-08-05)
+------------------
+
+**Added**
+
+* ``RequestException`` which wraps all exceptions that occur from
+ ``requests.request`` in a ``prawcore.RequestException``.
+
+**Changed**
+
+* What was previously ``RequestException`` is now ``ResponseException``.
+
+0.0.15 (2016-08-02)
+-------------------
+
+**Added**
+
+* Handle Cloudflair 522 responses.
+
+0.0.14 (2016-07-25)
+-------------------
+
+**Added**
+
+* Add ``ServerError`` exception for 502, 503, and 504 HTTP status codes that is
+ only raised after three failed attempts to make the request.
+* Add ``json`` parameter to ``Session.request``.
+
+0.0.13 (2016-07-24)
+-------------------
+
+**Added**
+
+* Automatically attempt to refresh access tokens when making a request if the
+ access token is expired.
+
+**Fixed**
+
+* Consider access tokens expired slightly earlier than allowed for to prevent
+ InvalidToken exceptions from occuring.
+
+0.0.12 (2016-07-17)
+-------------------
+
+**Added**
+
+* Handle 0-byte HTTP 200 responses.
+
+0.0.11 (2016-07-16)
+-------------------
+
+**Added**
+
+* Add a ``NotFound`` exception.
+* Support 404 "Not Found" HTTP responses.
+
+
+0.0.10 (2016-07-10)
+-------------------
+
+**Added**
+
+* Add a ``BadRequest`` exception.
+* Support 400 "Bad Request" HTTP responses.
+* Support 204 "No Content" HTTP responses.
+
+0.0.9 (2016-07-09)
+------------------
+
+**Added**
+
+* Support 201 "Created" HTTP responses used in some v1 endpoints.
+
+
+0.0.8 (2016-03-21)
+------------------
+
+**Added**
+
+* Sort ``Session.request`` ``data`` values. Sorting the values permits betamax
+ body matcher to work as expected.
+
+
+0.0.7 (2016-03-18)
+------------------
+
+**Added**
+
+* Added ``data`` parameter to ``Session.request``.
+
+0.0.6 (2016-03-14)
+------------------
+
+**Fixed**
+
+* prawcore objects can be pickled.
+
+0.0.5 (2016-03-12)
+------------------
+
+**Added**
+
+* 302 redirects result in a ``Redirect`` exception.
+
+0.0.4 (2016-03-12)
+------------------
+
+**Added**
+
+* Add a generic ``Forbidden`` exception for 403 responses without the
+ ``www-authenticate`` header.
+
+0.0.3 (2016-02-29)
+------------------
+
+**Added**
+
+* Added ``params`` parameter to ``Session.request``.
+* Log requests to the ``prawcore`` logger in debug mode.
+
+0.0.2 (2016-02-21)
+------------------
+
+**Fixed**
+
+* README.rst for display purposes on pypi.
+
+0.0.1 (2016-02-17) [YANKED]
+---------------------------
+
+**Added**
+
+* Dynamic rate limiting based on reddit's response headers.
+* Authorization URL generation.
+* Retrieval of access and refresh tokens from authorization grants.
+* Access and refresh token revocation.
+* Retrieval of read-only access tokens.
+* Retrieval of script-app tokens.
+* Three examples in the ``examples/`` directory.
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..11da918
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,74 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, gender identity and expression, level of experience,
+nationality, personal appearance, race, religion, or sexual identity and
+orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at bbzbryce at gmail.com. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..81a932a
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,22 @@
+Copyright (c) 2016, Bryce Boe
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..d896936
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+include *.md *.rst *.txt
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..af01413
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,116 @@
+Metadata-Version: 1.1
+Name: prawcore
+Version: 0.11.0
+Summary: Low-level communication layer for PRAW 4+.
+Home-page: https://github.com/praw-dev/prawcore
+Author: Bryce Boe
+Author-email: bbzbryce at gmail.com
+License: Simplified BSD License
+Description: .. _main_page:
+
+ prawcore
+ ========
+
+ .. image:: https://img.shields.io/pypi/v/prawcore.svg
+ :alt: Latest prawcore Version
+ :target: https://pypi.python.org/pypi/prawcore
+ .. image:: https://travis-ci.org/praw-dev/prawcore.svg?branch=master
+ :target: https://travis-ci.org/praw-dev/prawcore
+ .. image:: https://coveralls.io/repos/github/praw-dev/prawcore/badge.svg?branch=master
+ :target: https://coveralls.io/github/praw-dev/prawcore?branch=master
+ .. image:: https://badges.gitter.im/praw-dev/praw.svg
+ :alt: Join the chat at https://gitter.im/praw-dev/praw
+ :target: https://gitter.im/praw-dev/praw
+
+
+ prawcore is a low-level communication layer for PRAW 4+.
+
+
+ Installation
+ ------------
+
+ Install prawcore using ``pip`` via:
+
+ .. code-block:: console
+
+ pip install prawcore
+
+
+ Execution Example
+ -----------------
+
+ The following example demonstrates how to use prawcore to obtain the list of
+ trophies for a given user using the script-app type. This example assumes you
+ have the environment variables ``PRAWCORE_CLIENT_ID`` and
+ ``PRAWCORE_CLIENT_SECRET`` set to the appropriate values for your application.
+
+ .. code-block:: python
+
+ #!/usr/bin/env python
+ import os
+ import pprint
+ import prawcore
+
+ authenticator = prawcore.TrustedAuthenticator(
+ prawcore.Requestor('YOUR_VALID_USER_AGENT'),
+ os.environ['PRAWCORE_CLIENT_ID'],
+ os.environ['PRAWCORE_CLIENT_SECRET'])
+ authorizer = prawcore.ReadOnlyAuthorizer(authenticator)
+ authorizer.refresh()
+
+ with prawcore.session(authorizer) as session:
+ pprint.pprint(session.request('GET', '/api/v1/user/bboe/trophies'))
+
+ Save the above as ``trophies.py`` and then execute via:
+
+ .. code-block:: console
+
+ python trophies.py
+
+ Additional examples can be found at:
+ https://github.com/praw-dev/prawcore/tree/master/examples
+
+
+ Depending on prawcore
+ ---------------------
+
+ prawcore follows `semantic versioning <http://semver.org/>`_ with the exception
+ that deprecations will not be preceded by a minor release. In essense, expect
+ only major versions to introduce breaking changes to prawcore's public
+ interface. As a result, if you depend on prawcore then it is a good idea to
+ specify not only the minimum version of prawcore your package requires, but to
+ also limit the major version.
+
+ Below are two examples of how you may want to specify your prawcore dependency:
+
+ setup.py
+ ~~~~~~~~
+
+ .. code-block:: python
+
+ setup(...,
+ install_requires=['prawcore >=0.1, <1'],
+ ...)
+
+ requirements.txt
+ ~~~~~~~~~~~~~~~~
+
+ .. code-block:: text
+
+ prawcore >=1.5.1, <2
+
+Keywords: praw reddit api
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Natural Language :: English
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: Implementation :: CPython
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..ec46dd7
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,92 @@
+.. _main_page:
+
+prawcore
+========
+
+.. image:: https://img.shields.io/pypi/v/prawcore.svg
+ :alt: Latest prawcore Version
+ :target: https://pypi.python.org/pypi/prawcore
+.. image:: https://travis-ci.org/praw-dev/prawcore.svg?branch=master
+ :target: https://travis-ci.org/praw-dev/prawcore
+.. image:: https://coveralls.io/repos/github/praw-dev/prawcore/badge.svg?branch=master
+ :target: https://coveralls.io/github/praw-dev/prawcore?branch=master
+.. image:: https://badges.gitter.im/praw-dev/praw.svg
+ :alt: Join the chat at https://gitter.im/praw-dev/praw
+ :target: https://gitter.im/praw-dev/praw
+
+
+prawcore is a low-level communication layer for PRAW 4+.
+
+
+Installation
+------------
+
+Install prawcore using ``pip`` via:
+
+.. code-block:: console
+
+ pip install prawcore
+
+
+Execution Example
+-----------------
+
+The following example demonstrates how to use prawcore to obtain the list of
+trophies for a given user using the script-app type. This example assumes you
+have the environment variables ``PRAWCORE_CLIENT_ID`` and
+``PRAWCORE_CLIENT_SECRET`` set to the appropriate values for your application.
+
+.. code-block:: python
+
+ #!/usr/bin/env python
+ import os
+ import pprint
+ import prawcore
+
+ authenticator = prawcore.TrustedAuthenticator(
+ prawcore.Requestor('YOUR_VALID_USER_AGENT'),
+ os.environ['PRAWCORE_CLIENT_ID'],
+ os.environ['PRAWCORE_CLIENT_SECRET'])
+ authorizer = prawcore.ReadOnlyAuthorizer(authenticator)
+ authorizer.refresh()
+
+ with prawcore.session(authorizer) as session:
+ pprint.pprint(session.request('GET', '/api/v1/user/bboe/trophies'))
+
+Save the above as ``trophies.py`` and then execute via:
+
+.. code-block:: console
+
+ python trophies.py
+
+Additional examples can be found at:
+https://github.com/praw-dev/prawcore/tree/master/examples
+
+
+Depending on prawcore
+---------------------
+
+prawcore follows `semantic versioning <http://semver.org/>`_ with the exception
+that deprecations will not be preceded by a minor release. In essense, expect
+only major versions to introduce breaking changes to prawcore's public
+interface. As a result, if you depend on prawcore then it is a good idea to
+specify not only the minimum version of prawcore your package requires, but to
+also limit the major version.
+
+Below are two examples of how you may want to specify your prawcore dependency:
+
+setup.py
+~~~~~~~~
+
+.. code-block:: python
+
+ setup(...,
+ install_requires=['prawcore >=0.1, <1'],
+ ...)
+
+requirements.txt
+~~~~~~~~~~~~~~~~
+
+.. code-block:: text
+
+ prawcore >=1.5.1, <2
diff --git a/prawcore.egg-info/PKG-INFO b/prawcore.egg-info/PKG-INFO
new file mode 100644
index 0000000..af01413
--- /dev/null
+++ b/prawcore.egg-info/PKG-INFO
@@ -0,0 +1,116 @@
+Metadata-Version: 1.1
+Name: prawcore
+Version: 0.11.0
+Summary: Low-level communication layer for PRAW 4+.
+Home-page: https://github.com/praw-dev/prawcore
+Author: Bryce Boe
+Author-email: bbzbryce at gmail.com
+License: Simplified BSD License
+Description: .. _main_page:
+
+ prawcore
+ ========
+
+ .. image:: https://img.shields.io/pypi/v/prawcore.svg
+ :alt: Latest prawcore Version
+ :target: https://pypi.python.org/pypi/prawcore
+ .. image:: https://travis-ci.org/praw-dev/prawcore.svg?branch=master
+ :target: https://travis-ci.org/praw-dev/prawcore
+ .. image:: https://coveralls.io/repos/github/praw-dev/prawcore/badge.svg?branch=master
+ :target: https://coveralls.io/github/praw-dev/prawcore?branch=master
+ .. image:: https://badges.gitter.im/praw-dev/praw.svg
+ :alt: Join the chat at https://gitter.im/praw-dev/praw
+ :target: https://gitter.im/praw-dev/praw
+
+
+ prawcore is a low-level communication layer for PRAW 4+.
+
+
+ Installation
+ ------------
+
+ Install prawcore using ``pip`` via:
+
+ .. code-block:: console
+
+ pip install prawcore
+
+
+ Execution Example
+ -----------------
+
+ The following example demonstrates how to use prawcore to obtain the list of
+ trophies for a given user using the script-app type. This example assumes you
+ have the environment variables ``PRAWCORE_CLIENT_ID`` and
+ ``PRAWCORE_CLIENT_SECRET`` set to the appropriate values for your application.
+
+ .. code-block:: python
+
+ #!/usr/bin/env python
+ import os
+ import pprint
+ import prawcore
+
+ authenticator = prawcore.TrustedAuthenticator(
+ prawcore.Requestor('YOUR_VALID_USER_AGENT'),
+ os.environ['PRAWCORE_CLIENT_ID'],
+ os.environ['PRAWCORE_CLIENT_SECRET'])
+ authorizer = prawcore.ReadOnlyAuthorizer(authenticator)
+ authorizer.refresh()
+
+ with prawcore.session(authorizer) as session:
+ pprint.pprint(session.request('GET', '/api/v1/user/bboe/trophies'))
+
+ Save the above as ``trophies.py`` and then execute via:
+
+ .. code-block:: console
+
+ python trophies.py
+
+ Additional examples can be found at:
+ https://github.com/praw-dev/prawcore/tree/master/examples
+
+
+ Depending on prawcore
+ ---------------------
+
+ prawcore follows `semantic versioning <http://semver.org/>`_ with the exception
+ that deprecations will not be preceded by a minor release. In essense, expect
+ only major versions to introduce breaking changes to prawcore's public
+ interface. As a result, if you depend on prawcore then it is a good idea to
+ specify not only the minimum version of prawcore your package requires, but to
+ also limit the major version.
+
+ Below are two examples of how you may want to specify your prawcore dependency:
+
+ setup.py
+ ~~~~~~~~
+
+ .. code-block:: python
+
+ setup(...,
+ install_requires=['prawcore >=0.1, <1'],
+ ...)
+
+ requirements.txt
+ ~~~~~~~~~~~~~~~~
+
+ .. code-block:: text
+
+ prawcore >=1.5.1, <2
+
+Keywords: praw reddit api
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Natural Language :: English
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: Implementation :: CPython
diff --git a/prawcore.egg-info/SOURCES.txt b/prawcore.egg-info/SOURCES.txt
new file mode 100644
index 0000000..df80e09
--- /dev/null
+++ b/prawcore.egg-info/SOURCES.txt
@@ -0,0 +1,21 @@
+AUTHORS.rst
+CHANGES.rst
+CODE_OF_CONDUCT.md
+LICENSE.txt
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+prawcore/__init__.py
+prawcore/auth.py
+prawcore/const.py
+prawcore/exceptions.py
+prawcore/rate_limit.py
+prawcore/requestor.py
+prawcore/sessions.py
+prawcore/util.py
+prawcore.egg-info/PKG-INFO
+prawcore.egg-info/SOURCES.txt
+prawcore.egg-info/dependency_links.txt
+prawcore.egg-info/requires.txt
+prawcore.egg-info/top_level.txt
\ No newline at end of file
diff --git a/prawcore.egg-info/dependency_links.txt b/prawcore.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/prawcore.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/prawcore.egg-info/requires.txt b/prawcore.egg-info/requires.txt
new file mode 100644
index 0000000..33f749f
--- /dev/null
+++ b/prawcore.egg-info/requires.txt
@@ -0,0 +1 @@
+requests >=2.6.0, <3.0
diff --git a/prawcore.egg-info/top_level.txt b/prawcore.egg-info/top_level.txt
new file mode 100644
index 0000000..88f9ade
--- /dev/null
+++ b/prawcore.egg-info/top_level.txt
@@ -0,0 +1 @@
+prawcore
diff --git a/prawcore/__init__.py b/prawcore/__init__.py
new file mode 100644
index 0000000..5b3c67a
--- /dev/null
+++ b/prawcore/__init__.py
@@ -0,0 +1,13 @@
+"""prawcore: Low-level communication layer for PRAW 4+."""
+
+import logging
+from .auth import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer, # NOQA
+ ImplicitAuthorizer, ScriptAuthorizer, TrustedAuthenticator,
+ UntrustedAuthenticator)
+from .const import __version__ # noqa
+from .exceptions import * # noqa
+from .requestor import Requestor # noqa
+from .sessions import Session, session # noqa
+
+
+logging.getLogger(__package__).addHandler(logging.NullHandler())
diff --git a/prawcore/auth.py b/prawcore/auth.py
new file mode 100644
index 0000000..8bbd140
--- /dev/null
+++ b/prawcore/auth.py
@@ -0,0 +1,328 @@
+"""Provides Authentication and Authorization classes."""
+import time
+from . import const
+from .exceptions import InvalidInvocation, OAuthException, ResponseException
+from requests import Request
+from requests.status_codes import codes
+
+
+class BaseAuthenticator(object):
+ """Provide the base authenticator object that stores OAuth2 credentials."""
+
+ def __init__(self, requestor, client_id, redirect_uri=None):
+ """Represent a single authentication to Reddit's API.
+
+ :param requestor: An instance of :class:`Requestor`.
+ :param client_id: The OAuth2 client ID to use with the session.
+ :param redirect_uri: (optional) The redirect URI exactly as specified
+ in your OAuth application settings on Reddit. This parameter is
+ required if you want to use the ``authorize_url`` method, or the
+ ``authorize`` method of the ``Authorizer`` class.
+
+ """
+ self._requestor = requestor
+ self.client_id = client_id
+ self.redirect_uri = redirect_uri
+
+ def _post(self, url, success_status=codes['ok'], **data):
+ response = self._requestor.request('post', url, auth=self._auth(),
+ data=sorted(data.items()))
+ if response.status_code != success_status:
+ raise ResponseException(response)
+ return response
+
+ def authorize_url(self, duration, scopes, state, implicit=False):
+ """Return the URL used out-of-band to grant access to your application.
+
+ :param duration: Either ``permanent`` or ``temporary``. ``temporary``
+ authorizations generate access tokens that last only 1
+ hour. ``permanent`` authorizations additionally generate a refresh
+ token that can be indefinitely used to generate new hour-long
+ access tokens. Only ``temporary`` can be specified if ``implicit``
+ is set to ``True``.
+ :param scopes: A list of OAuth scopes to request authorization for.
+ :param state: A string that will be reflected in the callback to
+ ``redirect_uri``. This value should be temporarily unique to the
+ client for whom the URL was generated for.
+ :param implicit: (optional) Use the implicit grant flow (default:
+ False). This flow is only available for UntrustedAuthenticators.
+
+ """
+ if self.redirect_uri is None:
+ raise InvalidInvocation('redirect URI not provided')
+ if implicit and not isinstance(self, UntrustedAuthenticator):
+ raise InvalidInvocation('Only UntrustedAuthentictor instances can '
+ 'use the implicit grant flow.')
+ if implicit and duration != 'temporary':
+ raise InvalidInvocation('The implicit grant flow only supports '
+ 'temporary access tokens.')
+
+ params = {'client_id': self.client_id, 'duration': duration,
+ 'redirect_uri': self.redirect_uri,
+ 'response_type': 'token' if implicit else 'code',
+ 'scope': ' '.join(scopes), 'state': state}
+ url = self._requestor.reddit_url + const.AUTHORIZATION_PATH
+ request = Request('GET', url, params=params)
+ return request.prepare().url
+
+ def revoke_token(self, token, token_type=None):
+ """Ask Reddit to revoke the provided token.
+
+ :param token: The access or refresh token to revoke.
+ :param token_type: (Optional) When provided, hint to Reddit what the
+ token type is for a possible efficiency gain. The value can be
+ either ``access_token`` or ``refresh_token``.
+
+ """
+ data = {'token': token}
+ if token_type is not None:
+ data['token_type_hint'] = token_type
+ url = self._requestor.reddit_url + const.REVOKE_TOKEN_PATH
+ self._post(url, success_status=codes['no_content'], **data)
+
+
+class TrustedAuthenticator(BaseAuthenticator):
+ """Store OAuth2 authentication credentials for web, or script type apps."""
+
+ RESPONSE_TYPE = 'code'
+
+ def __init__(self, requestor, client_id, client_secret, redirect_uri=None):
+ """Represent a single authentication to Reddit's API.
+
+ :param requestor: An instance of :class:`Requestor`.
+ :param client_id: The OAuth2 client ID to use with the session.
+ :param client_secret: The OAuth2 client secret to use with the session.
+ :param redirect_uri: (optional) The redirect URI exactly as specified
+ in your OAuth application settings on Reddit. This parameter is
+ required if you want to use the ``authorize_url`` method, or the
+ ``authorize`` method of the ``Authorizer`` class.
+
+ """
+ super(TrustedAuthenticator, self).__init__(requestor, client_id,
+ redirect_uri)
+ self.client_secret = client_secret
+
+ def _auth(self):
+ return (self.client_id, self.client_secret)
+
+
+class UntrustedAuthenticator(BaseAuthenticator):
+ """Store OAuth2 authentication credentials for installed applications."""
+
+ def _auth(self):
+ return (self.client_id, '')
+
+
+class BaseAuthorizer(object):
+ """Superclass for OAuth2 authorization tokens and scopes."""
+
+ def __init__(self, authenticator):
+ """Represent a single authorization to Reddit's API.
+
+ :param authenticator: An instance of :class:`BaseAuthenticator`.
+
+ """
+ self._authenticator = authenticator
+ self._clear_access_token()
+ self._validate_authenticator()
+
+ def _clear_access_token(self):
+ self._expiration_timestamp = None
+ self.access_token = None
+ self.scopes = None
+
+ def _request_token(self, **data):
+ url = (self._authenticator._requestor.reddit_url +
+ const.ACCESS_TOKEN_PATH)
+ pre_request_time = time.time()
... 759 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/prawcore.git
More information about the Python-modules-commits
mailing list