From 935b1aeabedd6dd2eeaa7cf436ccff94edb84fb0 Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Thu, 4 Oct 2018 14:41:29 +0300 Subject: [PATCH 1/5] converted README and version as file --- .gitignore | 1 + MANIFEST.in | 4 +- README.md | 152 --------------------------- README.rst | 183 +++++++++++++++++++++++++++++++++ VERSION.txt | 1 + python_http_client/__init__.py | 7 ++ register.py | 24 ----- setup.cfg | 2 - setup.py | 25 +++-- 9 files changed, 210 insertions(+), 189 deletions(-) delete mode 100644 README.md create mode 100644 README.rst create mode 100644 VERSION.txt delete mode 100644 register.py delete mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index 0487142..29d5072 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ cleanup.sh *_example.py .idea README.txt +python_http_client/VERSION.txt diff --git a/MANIFEST.in b/MANIFEST.in index 42eb410..4d284ec 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,3 @@ -include LICENSE.txt +include LICENSE.txt VERSION.txt README.rst +recursive-include python_http_client *.py *.txt +prune tests diff --git a/README.md b/README.md deleted file mode 100644 index d1c62ad..0000000 --- a/README.md +++ /dev/null @@ -1,152 +0,0 @@ -![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png) - -[![BuildStatus](https://travis-ci.org/sendgrid/python-http-client.svg?branch=master)](https://travis-ci.org/sendgrid/python-http-client) -[![Email Notifications Badge](https://dx.sendgrid.com/badge/python)](https://dx.sendgrid.com/newsletter/python) -[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid) -[![Codecov branch](https://img.shields.io/codecov/c/github/sendgrid/python-http-client/master.svg?style=flat-square&label=Codecov+Coverage)](https://codecov.io/gh/sendgrid/python-http-client) -[![Code Climate](https://codeclimate.com/github/sendgrid/python-http-client/badges/gpa.svg)](https://codeclimate.com/github/sendgrid/python-http-client) -[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/python-http-client.svg)](https://github.com/sendgrid/python-http-client/graphs/contributors) -[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt) - -**Quickly and easily access any RESTful or RESTful-like API.** - -If you are looking for the SendGrid API client library, please see [this repo](https://github.com/sendgrid/sendgrid-python). - -# Table of Contents - -* [Installation](#installation) -* [Quick Start](#quick-start) -* [Usage](#usage) -* [Roadmap](#roadmap) -* [How to Contribute](#contribute) -- [Local set up](#local_setup) -* [Troubleshooting](#troubleshooting) -* [Announcements](#announcements) -* [Thanks](#thanks) -* [About](#about) -* [License](#license) - - -# Installation - -## Prerequisites - -- Python version 2.6, 2.7, 3.4, 3.5 or 3.6 - -## Install Package - -```bash -pip install python_http_client -``` - -or - -```bash -easy_install python_http_client -``` - -## API Key - -Store your SendGrid API key in a .env file - -```bash -cp .env_sample .env -``` - -Edit the `.env` file and add your API key. - - -# Quick Start - -Here is a quick example: - -`GET /your/api/{param}/call` - -```python -import python_http_client -global_headers = {"Authorization": "Basic XXXXXXX"} -client = Client(host='base_url', request_headers=global_headers) -client.your.api._(param).call.get() -print response.status_code -print response.headers -print response.body -``` - -`POST /your/api/{param}/call` with headers, query parameters and a request body with versioning. - -```python -import python_http_client -global_headers = {"Authorization": "Basic XXXXXXX"} -client = Client(host='base_url', request_headers=global_headers) -query_params={"hello":0, "world":1} -request_headers={"X-Test": "test"} -data={"some": 1, "awesome": 2, "data": 3} -response = client.your.api._(param).call.post(request_body=data, - query_params=query_params, - request_headers=request_headers) -print response.status_code -print response.headers -print response.body -``` - - -# Usage - -- [Example Code](https://github.com/sendgrid/python-http-client/tree/master/examples) - - -# Roadmap - -If you are interested in the future direction of this project, please take a look at our [milestones](https://github.com/sendgrid/python-http-client/milestones). We would love to hear your feedback. - - -# How to Contribute - -We encourage contribution to our projects, please see our [CONTRIBUTING](https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md) guide for details. - -Quick links: - -- [Feature Request](https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#feature-request) -- [Bug Reports](https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#submit-a-bug-report) -- [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#cla) -- [Improvements to the Codebase](https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#improvements-to-the-codebase) -- [Review Pull Requests](https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#code-reviews) - - - -# Local Setup of the project - -The simplest local development workflow is by using docker. - -> Steps - -1. Install Docker -2. Run `docker-compose build` (This builds the container) -3. Run `docker-compose up` (This runs tests by default) - - -# Troubleshooting - -Please see our [troubleshooting guide](https://github.com/sendgrid/python-http-client/blob/master/TROUBLESHOOTING.md) for any issues. - - -# Announcements - -All updates to this project is documented in our [CHANGELOG](https://github.com/sendgrid/python-http-client/blob/master/CHANGELOG.md). - - -# Thanks - -We were inspired by the work done on [birdy](https://github.com/inueni/birdy) and [universalclient](https://github.com/dgreisen/universalclient). - - -# About - -python-http-client is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com). - -python-http-client is maintained and funded by SendGrid, Inc. The names and logos for python-http-client are trademarks of SendGrid, Inc. - - -# License - -[The MIT License (MIT)](LICENSE.txt) diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..04111a5 --- /dev/null +++ b/README.rst @@ -0,0 +1,183 @@ +.. image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png + :target: https://www.sendgrid.com + +|Build Status| |Email Notifications Badge| |Twitter Follow| |Codecov branch| |Code Climate| |GitHub contributors| |MIT licensed| + +**Quickly and easily access any RESTful or RESTful-like API.** + +If you are looking for the SendGrid API client library, please see `this repo`_. + +Table of Contents +================= + +- `Installation <#installation>`__ +- `Quick Start <#quick-start>`__ +- `Usage <#usage>`__ +- `Roadmap <#roadmap>`__ +- `How to Contribute <#how-to-contribute>`__ +- `Local Setup of the Project <#local-setup-of-the-project>`__ +- `Troubleshooting <#troubleshooting>`__ +- `Announcements <#announcements>`__ +- `Thanks <#thanks>`__ +- `About <#about>`__ +- `License <#license>`__ + +Installation +============ + +Prerequisites +------------- + +- Python version 2.6, 2.7, 3.4, 3.5 or 3.6 + +Install Package +--------------- + +.. code:: bash + + pip install python_http_client + +or + +.. code:: bash + + easy_install python_http_client + +API Key +------- + +Store your SendGrid API key in a ``.env`` file. + +.. code:: bash + + cp .env_sample .env + +Edit the ``.env`` file and add your API key. + +Quick Start +=========== + +Here is a quick example: + +``GET /your/api/{param}/call`` + +.. code:: python + + import python_http_client + + global_headers = {"Authorization": "Basic XXXXXXX"} + client = Client(host='base_url', request_headers=global_headers) + client.your.api._(param).call.get() + print(response.status_code) + print(response.headers) + print(response.body) + +``POST /your/api/{param}/call`` with headers, query parameters and a request body with versioning. + +.. code:: python + + import python_http_client + + global_headers = {"Authorization": "Basic XXXXXXX"} + client = Client(host='base_url', request_headers=global_headers) + query_params = {"hello":0, "world":1} + request_headers = {"X-Test": "test"} + data = {"some": 1, "awesome": 2, "data": 3} + response = client.your.api._(param).call.post(request_body=data, + query_params=query_params, + request_headers=request_headers) + print(response.status_code) + print(response.headers) + print(response.body) + +Usage +===== + +- `Example Code`_ + +Roadmap +======= + +If you are interested in the future direction of this project, please take a look at our `milestones`_. +We would love to hear your feedback. + +How to Contribute +================= + +We encourage contribution to our projects, please see our `CONTRIBUTING`_ guide for details. + +Quick links: + +- `Feature Request`_ +- `Bug Reports`_ +- `Sign the CLA to Create a Pull Request`_ +- `Improvements to the Codebase`_ +- `Review Pull Requests`_ + +Local Setup of the Project +========================== + +The simplest local development workflow is by using docker. + +1. Install Docker +2. Run ``docker-compose build`` (this builds the container) +3. Run ``docker-compose up`` (this runs tests by default) + +Troubleshooting +=============== + +Please see our `troubleshooting guide`_ for any issues. + +Announcements +============= + +All updates to this project is documented in our `CHANGELOG`_. + +Thanks +====== + +We were inspired by the work done on `birdy`_ and `universalclient`_. + +About +===== + +**python-http-client** is guided and supported by the SendGrid `Developer Experience Team`_. + +**python-http-client** is maintained and funded by SendGrid, Inc. +The names and logos for **python-http-client** are trademarks of SendGrid, Inc. + +License +======= + +`The MIT License (MIT)`_ + +.. _this repo: https://github.com/sendgrid/sendgrid-python +.. _Example Code: https://github.com/sendgrid/python-http-client/tree/master/examples +.. _milestones: https://github.com/sendgrid/python-http-client/milestones +.. _CONTRIBUTING: https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md +.. _Feature Request: https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#feature-request +.. _Bug Reports: https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#submit-a-bug-report +.. _Sign the CLA to Create a Pull Request: https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#cla +.. _Improvements to the Codebase: https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#improvements-to-the-codebase +.. _Review Pull Requests: https://github.com/sendgrid/python-http-client/blob/master/CONTRIBUTING.md#code-reviews +.. _troubleshooting guide: https://github.com/sendgrid/python-http-client/blob/master/TROUBLESHOOTING.md +.. _CHANGELOG: https://github.com/sendgrid/python-http-client/blob/master/CHANGELOG.md +.. _birdy: https://github.com/inueni/birdy +.. _universalclient: https://github.com/dgreisen/universalclient +.. _Developer Experience Team: mailto:dx@sendgrid.com +.. _The MIT License (MIT): LICENSE.txt + +.. |Build Status| image:: https://travis-ci.org/sendgrid/python-http-client.svg?branch=master + :target: https://travis-ci.org/sendgrid/python-http-client +.. |Email Notifications Badge| image:: https://dx.sendgrid.com/badge/python + :target: https://dx.sendgrid.com/newsletter/python +.. |Twitter Follow| image:: https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow + :target: https://twitter.com/sendgrid +.. |Codecov branch| image:: https://img.shields.io/codecov/c/github/sendgrid/python-http-client/master.svg?style=flat-square&label=Codecov+Coverage + :target: https://codecov.io/gh/sendgrid/python-http-client +.. |Code Climate| image:: https://codeclimate.com/github/sendgrid/python-http-client/badges/gpa.svg + :target: https://codeclimate.com/github/sendgrid/python-http-client +.. |GitHub contributors| image:: https://img.shields.io/github/contributors/sendgrid/python-http-client.svg + :target: https://github.com/sendgrid/python-http-client/graphs/contributors +.. |MIT licensed| image:: https://img.shields.io/badge/license-MIT-blue.svg + :target: https://github.com/sendgrid/python-http-client/blob/master/LICENSE.txt diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..fd2a018 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +3.1.0 diff --git a/python_http_client/__init__.py b/python_http_client/__init__.py index d7052b8..0d88104 100644 --- a/python_http_client/__init__.py +++ b/python_http_client/__init__.py @@ -1,3 +1,5 @@ +import os + from .client import Client # noqa from .exceptions import ( # noqa HTTPError, @@ -13,3 +15,8 @@ ServiceUnavailableError, GatewayTimeoutError ) + + +dir_path = os.path.dirname(os.path.realpath(__file__)) +if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')): + __version__ = open(os.path.join(dir_path, 'VERSION.txt')).read().strip() diff --git a/register.py b/register.py deleted file mode 100644 index f42994f..0000000 --- a/register.py +++ /dev/null @@ -1,24 +0,0 @@ -import pypandoc - - -output = pypandoc.convert('README.md', 'rst') - -with open('README.txt', 'w+') as f: - f.write(output) - -readme_rst = open('./README.txt').read() - -replace = """\ -[SendGrid Logo] -(https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)""" - -replacement = """\ -|SendGrid Logo| - -.. |SendGrid Logo| image:: \ -https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png - :target: https://www.sendgrid.com""" - -final_text = readme_rst.replace(replace, replacement) -with open('./README.txt', 'w') as f: - f.write(final_text) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 224a779..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py index 52fa6a9..9d8d394 100755 --- a/setup.py +++ b/setup.py @@ -1,11 +1,8 @@ -import sys +import io import os -from setuptools import setup - - -long_description = 'Please see our GitHub README' -if os.path.exists('README.txt'): - long_description = open('README.txt').read() +import sys +from distutils.file_util import copy_file +from setuptools import find_packages, setup def get_requires(): @@ -15,8 +12,15 @@ def get_requires(): return deps +dir_path = os.path.abspath(os.path.dirname(__file__)) +readme = io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8').read() +version = io.open(os.path.join(dir_path, 'VERSION.txt'), encoding='utf-8').read().strip() base_url = 'https://github.com/sendgrid/' -version = '3.1.0' + +copy_file(os.path.join(dir_path, 'VERSION.txt'), + os.path.join(dir_path, 'python_http_client', 'VERSION.txt'), + verbose=0) + setup( name='python_http_client', version=version, @@ -24,10 +28,11 @@ def get_requires(): author_email='dx@sendgrid.com', url='{0}python-http-client'.format(base_url), download_url='{0}python-http-client/tarball/{1}'.format(base_url, version), - packages=['python_http_client'], + packages=find_packages(), + include_package_data=True, license='MIT', description='HTTP REST client, simplified for Python', - long_description=long_description, + long_description=readme, install_requires=get_requires(), keywords=[ 'REST', From 7f735ae3fe72ede3a4ec847489230e0f131a31df Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Thu, 4 Oct 2018 16:21:25 +0300 Subject: [PATCH 2/5] updated tests --- tests/test_repofiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_repofiles.py b/tests/test_repofiles.py index 544ce77..2037349 100644 --- a/tests/test_repofiles.py +++ b/tests/test_repofiles.py @@ -19,7 +19,7 @@ class RepoFiles(unittest.TestCase): ['./.github/ISSUE_TEMPLATE'], ['./LICENSE.md', './LICENSE.txt'], ['./.github/PULL_REQUEST_TEMPLATE'], - ['./README.md'], + ['./README.rst'], ['./TROUBLESHOOTING.md'], ['./USAGE.md'], ['./USE_CASES.md'] From a5f5e147900e0957575797a99d63adefa0f8d5a5 Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Thu, 4 Oct 2018 17:20:05 +0300 Subject: [PATCH 3/5] hotfix URL --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 04111a5..b9d4485 100644 --- a/README.rst +++ b/README.rst @@ -165,7 +165,7 @@ License .. _birdy: https://github.com/inueni/birdy .. _universalclient: https://github.com/dgreisen/universalclient .. _Developer Experience Team: mailto:dx@sendgrid.com -.. _The MIT License (MIT): LICENSE.txt +.. _The MIT License (MIT): https://github.com/sendgrid/python-http-client/blob/master/LICENSE.txt .. |Build Status| image:: https://travis-ci.org/sendgrid/python-http-client.svg?branch=master :target: https://travis-ci.org/sendgrid/python-http-client From d108dfbe25fb6053dc8686d8f6a79a47f7d8993c Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Thu, 4 Oct 2018 18:38:14 +0300 Subject: [PATCH 4/5] updated test --- tests/test_repofiles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_repofiles.py b/tests/test_repofiles.py index 2037349..c57ace1 100644 --- a/tests/test_repofiles.py +++ b/tests/test_repofiles.py @@ -22,7 +22,8 @@ class RepoFiles(unittest.TestCase): ['./README.rst'], ['./TROUBLESHOOTING.md'], ['./USAGE.md'], - ['./USE_CASES.md'] + ['./USE_CASES.md'], + ['./VERSION.txt'] ] def _all_file(self, files): From 04b8453c4e0be01c32a6138d38e70f8ec32d7b89 Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Thu, 4 Oct 2018 20:05:46 +0300 Subject: [PATCH 5/5] added PyPI version and Python versions badges --- README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index b9d4485..24721d4 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ .. image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png :target: https://www.sendgrid.com -|Build Status| |Email Notifications Badge| |Twitter Follow| |Codecov branch| |Code Climate| |GitHub contributors| |MIT licensed| +|Build Status| |Email Notifications Badge| |Twitter Follow| |Codecov branch| |Code Climate| |Python Versions| |PyPI Version| |GitHub contributors| |MIT licensed| **Quickly and easily access any RESTful or RESTful-like API.** @@ -177,6 +177,10 @@ License :target: https://codecov.io/gh/sendgrid/python-http-client .. |Code Climate| image:: https://codeclimate.com/github/sendgrid/python-http-client/badges/gpa.svg :target: https://codeclimate.com/github/sendgrid/python-http-client +.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/python-http-client.svg + :target: https://pypi.org/project/python-http-client +.. |PyPI Version| image:: https://img.shields.io/pypi/v/python-http-client.svg + :target: https://pypi.org/project/python-http-client .. |GitHub contributors| image:: https://img.shields.io/github/contributors/sendgrid/python-http-client.svg :target: https://github.com/sendgrid/python-http-client/graphs/contributors .. |MIT licensed| image:: https://img.shields.io/badge/license-MIT-blue.svg