Commit 699e494b authored by Irene "Tissy" Pirrotta's avatar Irene "Tissy" Pirrotta
Browse files

feature: Add python3-status library.

parents
Pipeline #3042 failed with stages
For `status.py` file:
originally from: https://github.com/tomchristie/django-rest-framework/blob/master/LICENSE.md
Copyright (c) 2011-2015, Tom Christie
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
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.
---
every other piece of code follows same license mentioned earlier, but copyright notice is:
Copyright (c) 2015 Avinash Sajjanshetty <hi@avi.im>
Metadata-Version: 1.1
Name: python-status
Version: 1.0.1
Summary: HTTP Status for Humans
Home-page: https://github.com/avinassh/status/
Author: Avinash Sajjanshetty
Author-email: hi@avi.im
License: BSD
Description: # status - HTTP Status for Humans
[![version](https://img.shields.io/pypi/v/python-status.svg)](https://pypi.python.org/pypi/python-status/)
[![supported](https://img.shields.io/pypi/pyversions/python-status.svg)](https://pypi.python.org/pypi/python-status/)
![license](https://img.shields.io/pypi/l/python-status.svg)
`status` is a very simple python library which provides human understandable HTTP status codes and improves readability of your code. You don't have to use those ugly HTTP status numbers, but use easily understandable status names.
Don't:
class PythonPeople(RequestHandler):
def post(self):
# do stuff
return ('That worked!', 201)
But, do this:
class PythonPeople(RequestHandler):
def post(self):
# do stuff
return ('That worked!', status.HTTP_201_CREATED)
See, that looks so much better. You can use this library wherever you want, from custom python scripts to Django, Flask etc apps. For example, if you were playing with [Requests](http://python-requests.org):
>>> response = requests.delete('http://some-url')
>>> response.status_code == status.HTTP_204_NO_CONTENT
## Installation
pip install python-status
## Usage
`status` comes with HTTP response status codes and also some helpful methods to check the response status. Under the hood, status codes are merely an integer variable with meaningful variable names. Check `status.py` file.
>>> import status
>>> status.HTTP_200_OK == 200
True
For list of available status codes check `status.py` file.
`status` also comes with some helpful methods to check the status of a response. They are `status.is_informational`, `status.is_success`, `status.is_redirect`, `status.is_client_error` and `status.is_server_error`.
>>> import status
>>> response = requests.delete('http://some-url')
>>> if status.is_success(code=response.status_code):
print('yay!')
>>>
yay!
# Why?
For every project I was creating a `status.py` file in the root directory. So I thought it's better to release this as a package on PyPi and use it.
# License
Please check `LICENSE` for more details.
# Credits
`status` is a fork of [Django Rest Framework](https://github.com/tomchristie/django-rest-framework)(DRF) and is independently maintained. The fork is entirely stripped of all DRF features and is not a submodule of DRF. And it doesn't come with any DRF functionalities.
Platform: UNKNOWN
Classifier: Development Status :: 6 - Mature
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
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: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
# status - HTTP Status for Humans
[![version](https://img.shields.io/pypi/v/python-status.svg)](https://pypi.python.org/pypi/python-status/)
[![supported](https://img.shields.io/pypi/pyversions/python-status.svg)](https://pypi.python.org/pypi/python-status/)
![license](https://img.shields.io/pypi/l/python-status.svg)
`status` is a very simple python library which provides human understandable HTTP status codes and improves readability of your code. You don't have to use those ugly HTTP status numbers, but use easily understandable status names.
Don't:
class PythonPeople(RequestHandler):
def post(self):
# do stuff
return ('That worked!', 201)
But, do this:
class PythonPeople(RequestHandler):
def post(self):
# do stuff
return ('That worked!', status.HTTP_201_CREATED)
See, that looks so much better. You can use this library wherever you want, from custom python scripts to Django, Flask etc apps. For example, if you were playing with [Requests](http://python-requests.org):
>>> response = requests.delete('http://some-url')
>>> response.status_code == status.HTTP_204_NO_CONTENT
## Installation
pip install python-status
## Usage
`status` comes with HTTP response status codes and also some helpful methods to check the response status. Under the hood, status codes are merely an integer variable with meaningful variable names. Check `status.py` file.
>>> import status
>>> status.HTTP_200_OK == 200
True
For list of available status codes check `status.py` file.
`status` also comes with some helpful methods to check the status of a response. They are `status.is_informational`, `status.is_success`, `status.is_redirect`, `status.is_client_error` and `status.is_server_error`.
>>> import status
>>> response = requests.delete('http://some-url')
>>> if status.is_success(code=response.status_code):
print('yay!')
>>>
yay!
# Why?
For every project I was creating a `status.py` file in the root directory. So I thought it's better to release this as a package on PyPi and use it.
# License
Please check `LICENSE` for more details.
# Credits
`status` is a fork of [Django Rest Framework](https://github.com/tomchristie/django-rest-framework)(DRF) and is independently maintained. The fork is entirely stripped of all DRF features and is not a submodule of DRF. And it doesn't come with any DRF functionalities.
python3-status (1.0.1-1) rolling; urgency=medium
* Initial release
-- Irene "tissy" Pirrotta <tissy@parrotsec.org> Thu, 29 Apr 2021 09:47:09 +0100
Source: python3-status
Section: python
Priority: optional
Maintainer: Parrot Team <team@parrotsec.org>
Uploaders: Irene "Tissy" Pirrotta <tissy@parrotsec.org>
Build-Depends: debhelper-compat (= 13),
dh-python,
python3,
python3-all,
python3-setuptools
Standards-Version: 4.5.1
Homepage: https://github.com/avinassh/status/
#Vcs-Browser: https://salsa.debian.org/debian/python-status
#Vcs-Git: https://salsa.debian.org/debian/python-status.git
Rules-Requires-Root: no
Package: python3-status
Architecture: any
Depends: ${python3:Depends}, ${misc:Depends}
Description: HTTP Status for Humans
status is a very simple python library which provides human understandable HTTP status codes and improves readability of your code. You don't have to use those ugly HTTP status numbers, but use easily understandable status names.
For `status.py` file:
originally from: https://github.com/tomchristie/django-rest-framework/blob/master/LICENSE.md
Copyright (c) 2011-2015, Tom Christie
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
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.
---
every other piece of code follows same license mentioned earlier, but copyright notice is:
Copyright (c) 2015 Avinash Sajjanshetty <hi@avi.im>
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export PYBUILD_NAME = python3-status
%:
dh $@ --with python3 --buildsystem=pybuild
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
#!/usr/bin/env python
from distutils.core import setup
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except (ImportError, IOError):
long_description = open('README.md').read()
version = '1.0.1'
setup(
name='python-status',
version=version,
author='Avinash Sajjanshetty',
author_email='hi@avi.im',
py_modules=['status'],
url='https://github.com/avinassh/status/',
license='BSD',
description='HTTP Status for Humans',
long_description=long_description,
classifiers=[
'Development Status :: 6 - Mature',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
)
"""
source: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/status.py
Copyright (c) 2011-2015, Tom Christie All rights reserved.
Descriptive HTTP status codes, for code readability.
See RFC 2616 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
And RFC 6585 - http://tools.ietf.org/html/rfc6585
"""
from __future__ import unicode_literals
def is_informational(code):
return 100 <= code <= 199
def is_success(code):
return 200 <= code <= 299
def is_redirect(code):
return 300 <= code <= 399
def is_client_error(code):
return 400 <= code <= 499
def is_server_error(code):
return 500 <= code <= 599
HTTP_100_CONTINUE = 100
HTTP_101_SWITCHING_PROTOCOLS = 101
HTTP_200_OK = 200
HTTP_201_CREATED = 201
HTTP_202_ACCEPTED = 202
HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203
HTTP_204_NO_CONTENT = 204
HTTP_205_RESET_CONTENT = 205
HTTP_206_PARTIAL_CONTENT = 206
HTTP_300_MULTIPLE_CHOICES = 300
HTTP_301_MOVED_PERMANENTLY = 301
HTTP_302_FOUND = 302
HTTP_303_SEE_OTHER = 303
HTTP_304_NOT_MODIFIED = 304
HTTP_305_USE_PROXY = 305
HTTP_306_RESERVED = 306
HTTP_307_TEMPORARY_REDIRECT = 307
HTTP_400_BAD_REQUEST = 400
HTTP_401_UNAUTHORIZED = 401
HTTP_402_PAYMENT_REQUIRED = 402
HTTP_403_FORBIDDEN = 403
HTTP_404_NOT_FOUND = 404
HTTP_405_METHOD_NOT_ALLOWED = 405
HTTP_406_NOT_ACCEPTABLE = 406
HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407
HTTP_408_REQUEST_TIMEOUT = 408
HTTP_409_CONFLICT = 409
HTTP_410_GONE = 410
HTTP_411_LENGTH_REQUIRED = 411
HTTP_412_PRECONDITION_FAILED = 412
HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413
HTTP_414_REQUEST_URI_TOO_LONG = 414
HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415
HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416
HTTP_417_EXPECTATION_FAILED = 417
HTTP_418_I_AM_A_TEAPOT = 418
HTTP_428_PRECONDITION_REQUIRED = 428
HTTP_429_TOO_MANY_REQUESTS = 429
HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE = 431
HTTP_500_INTERNAL_SERVER_ERROR = 500
HTTP_501_NOT_IMPLEMENTED = 501
HTTP_502_BAD_GATEWAY = 502
HTTP_503_SERVICE_UNAVAILABLE = 503
HTTP_504_GATEWAY_TIMEOUT = 504
HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505
HTTP_511_NETWORK_AUTHENTICATION_REQUIRED = 511
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment