Skip to content

Commit

Permalink
comply with flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
discdiver committed May 20, 2019
1 parent 6f9cac6 commit f87c9eb
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 185 deletions.
11 changes: 6 additions & 5 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Types of Contributions
Report Security Vulnerabilities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you think you have found a security vulnerability,
please email jeffmshale at gmail dot com.
If you think you have found a security vulnerability,
please email jeffmshale at gmail dot com.

Please don't report it in an issue or any other public forum.

Expand All @@ -39,7 +39,8 @@ If you are reporting a bug, please include:
Fix Bugs
~~~~~~~~

Feel free to look through the GitHub issues for bugs. Anything tagged with "bug" and "help
Feel free to look through the GitHub issues for bugs.
Anything tagged with "bug" and "help
wanted" is open to whoever wants to fix it.

Implement Features
Expand Down Expand Up @@ -87,7 +88,7 @@ Ready to contribute? Here's how to set up `pybraries` for local development.

git clone git@github.com:your_github_username_here/pybraries.git

3. Install your local copy into a virtual environment.
3. Install your local copy into a virtual environment.

4. Create a branch for local development::

Expand All @@ -97,7 +98,7 @@ Ready to contribute? Here's how to set up `pybraries` for local development.

5. When you're done making changes, check that your changes pass::

pytest
pytest

6. Commit your changes and push your branch to GitHub::

Expand Down
26 changes: 14 additions & 12 deletions docs/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ Pybraries
.. image:: https://travis-ci.org/pybraries/pybraries.svg?branch=master
:target: https://travis-ci.org/pybraries/pybraries

.. image:: https://coveralls.io/repos/github/pybraries/pybraries/badge.svg?branch=master
:alt: coveralls
.. image:: https://coveralls.io/repos/github/pybraries/pybraries/badge.svg?branch=master
:alt: coveralls
:target: https://coveralls.io/github/pybraries/pybraries?branch=master

.. image:: https://readthedocs.org/projects/pybraries/badge/?version=latest
:target: https://pybraries.readthedocs.io/en/latest/?badge=latest
.. image:: https://readthedocs.org/projects/pybraries/badge/?version=latest
:target: https://pybraries.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

Pybraries is a Python wrapper for the libraries.io API.

Use it to subscribe to and unsubscribe from upates to packages on any package manager.
Pybraries is a Python wrapper for the libraries.io API.

You can also use pybraries to find information about many aspects related to packages and projects.
Use it to subscribe to and unsubscribe from upates
to packages on any package manager.

You can also use pybraries to find information about
many aspects related to packages and projects.

Quick Start
-----------
Expand All @@ -44,12 +46,12 @@ Import the pybraries package and use it.
from pybraries import Libraries_API
api = Libraries_API()
api = Libraries_API()
api.subscribe("pypi", "pandas")
Now you're subscribed to updates to the pandas package.
Info about the package will be returned.
Now you're subscribed to updates to the pandas package.
Info about the package will be returned.

Note that the Libraries.io API is rate limited to 60 requests per minute.

Expand All @@ -70,4 +72,4 @@ _______

.. _contributing: https://pybraries.readthedocs.io/contributing
.. _documentation: https://pybraries.readthedocs.io
.. _libraries.io: https://libraries.io
.. _libraries.io: https://libraries.io
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Usage

Use the pybraries API wrapper in a project to return a package name.

Set your the api_key environment variable to your libraries.io api_key.
Set your the api_key environment variable to your libraries.io api_key.

.. code:: python
Expand Down
15 changes: 6 additions & 9 deletions pybraries/helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os
import requests
from requests.exceptions import HTTPError, RetryError
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter

LIBRARIES_API_KEY = os.environ.get('LIBRARIES_API_KEY', None)
LIBRARIES_API_KEY = os.environ.get("LIBRARIES_API_KEY", None)


class APIKeyMissingError(Exception):
pass


if LIBRARIES_API_KEY is None:
raise APIKeyMissingError(
"All methods require an API key. "
Expand All @@ -17,15 +18,11 @@ class APIKeyMissingError(Exception):
)

# session retry settings
retries = Retry(
total=3,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
retries = Retry(total=3, backoff_factor=0.2, status_forcelist=[500, 502, 503, 504])

# session object common properties
sess = requests.Session()
sess.params = {}
sess.params['api_key'] = LIBRARIES_API_KEY
sess.params["api_key"] = LIBRARIES_API_KEY
# sess.params['timeout'] = 5
sess.mount('https://', HTTPAdapter(max_retries=retries))
sess.mount("https://", HTTPAdapter(max_retries=retries))

0 comments on commit f87c9eb

Please sign in to comment.