This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A simple HTTP status code/name/description library for Python.

Uses the six library for Python 2/3 compatability.

Installation

Either install via pip:

$ pip install http_status

Or clone the git repo, and run setup.py:

$ git clone https://github.com/DanielOaks/http_status.git
Cloning into 'http_status'...
[...]
Unpacking objects: 100% (18/18), done.

$ cd http_status/

$ python setup.py build install
running build
[...]
Writing /usr/local/lib/python2.7/site-packages/http_status-0.1.0a-py2.7.egg-info

Usage

Use by itself:

>>> import http_status
>>> http_status.name[302]
'Found'
>>> http_status.description[302]
'URI of this resource has changed, temporarily.'

Use of the Status object:

>>> from http_status import Status
>>> s = Status(403)
>>> s.code
403
>>> s.name
'Forbidden'
>>> s.description
'Client does not have rights to access the content.'

>>> s.code = 405
>>> s.name
'Method Not Allowed'
>>> s.description
'Server has disabled this request method and cannot be used.'

Status() only accepts ‘valid’ HTTP status codes, ints from 100 to 599 as per RFC. If an invalid code is given, it will throw an InvalidHttpCode exception:

>>> from http_status import Status
>>> s = Status(9999)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/http_status/__init__.py", line 279, in __init__
    self.code = code
  File "/usr/local/lib/python2.7/site-packages/http_status/__init__.py", line 301, in code
    self._code = validate_http_code(http_code, strict=self.strict)
  File "/usr/local/lib/python2.7/site-packages/http_status/__init__.py", line 262, in validate_http_code
    raise InvalidHttpCode('{} is above maximum HTTP status code {}'.format(http_code, maximum))
http_status.InvalidHttpCode: 9999 is above maximum HTTP status code 599

However, it can be set to nonstrict to not throw exceptions, and simply return the standard name/description not found for invalid objects, as such:

>>> from http_status import Status
>>> s = Status(9999, strict=False)
>>> s
<http_status.Status object at 0x1101905d0>
>>> s.name
'No HTTP Name'
>>> s.code
0

Note that if the Status object does not have a name/description matching the given code, it will return default strings (for compatability when directly inserting Status.name and Status.description into format strings.

This can be changed by passing arguments name_fail and description_fail when you create Status:

>>> from http_status import Status
>>> s = Status(243)
>>> s.name
'No HTTP Name'
>>> s.description
'No HTTP Description.'

>>> from http_status import Status
>>> s = Status(243, name_fail='Nothing', description_fail='Nothing at all')
>>> s.name
'Nothing'
>>> s.description
'Nothing at all'

The class NoneStatus is exactly the same as Status, but name_fail and description_fail both default to None.

License

Copyright (c) 2014 Daniel Oaks and contributors

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.

Six Library License

Copyright (c) 2010-2014 Benjamin Peterson

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.

Release History

Release History

1.0.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0a

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
http-status-1.0.0.macosx-10.8-x86_64.exe (82.7 kB) Copy SHA256 Checksum SHA256 any Windows Installer Jun 7, 2014
http-status-1.0.0.tar.gz (13.7 kB) Copy SHA256 Checksum SHA256 Source Jun 7, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting