Skip to main content

Version ReadTheDocs Build Coverage CodeClimate

Wait… Why? What??

This is a gut reaction to the wealth of ways to parse URLs, MIME headers, HTTP messages and other things described by IETF RFCs. They range from the Python standard library (urllib) to be buried in the guts of other kitchen sink libraries (werkzeug) and most of them are broken in one way or the other.

So why create another one? Good question… glad that you asked. This is a companion library to the great packages out there that are responsible for communicating with other systems. I’m going to concentrate on providing a crisp and usable set of APIs that concentrate on parsing text. Nothing more. Hopefully by concentrating on the specific task of parsing things, the result will be a beautiful and usable interface to the text strings that power the Internet world.

Here’s a sample of the code that this library lets you write:

from ietfparse import algorithms, headers

def negotiate_versioned_representation(request, handler, data_dict):
    requested = headers.parse_accept(request.headers['Accept'])
    selected = algorithms.select_content_type(requested, [
        headers.parse_content_type('application/example+json; v=1'),
        headers.parse_content_type('application/example+json; v=2'),
        headers.parse_content_type('application/json'),
    ])

    output_version = selected.parameters.get('v', '2')
    if output_version == '1':
        handler.set_header('Content-Type', 'application/example+json; v=1')
        handler.write(generate_legacy_json(data_dict))
    else:
        handler.set_header('Content-Type', 'application/example+json; v=2')
        handler.write(generate_modern_json(data_dict))

def redirect_to_peer(host, port=80):
    flask.redirect(algorithms.rewrite_url(flask.request.url,
                                          host=host, port=port))

OK… Where?

Source

https://github.com/dave-shawley/ietfparse

Status

https://circleci.com/gh/dave-shawley/ietfparse/tree/master

Download

https://pypi.org/project/ietfparse

Documentation

https://ietfparse.readthedocs.io/en/latest

Issues

https://github.com/dave-shawley/ietfparse

Metadata

Release files for ietfparse 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ietfparse 1.9.0
File Size Uploaded
ietfparse-1.9.0.tar.gz 38.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ietfparse 1.9.0
File Interpreter ABI Platform
ietfparse-1.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.5 kB

Release files / ietfparse-1.9.0.tar.gz

Download URL ietfparse-1.9.0.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2a5e7006f742e42a3651cd24d16f050acdf7ae4d0ae0cd576f3f4abc150dc5b3
BLAKE2b-256 checksum
How to use checksums
1fd95347ee8ff3765800d4aaab7d6a9816ac4ed6fee4fbafcf6cb8ffc58c3094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / ietfparse-1.9.0-py3-none-any.whl

Download URL ietfparse-1.9.0-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72216d31d94764156c4380c419af41295b53a1b309dd8091e5610a411c8b5446
BLAKE2b-256 checksum
How to use checksums
11ac5c6e72985228dee72e25a28b12ad97746832c9cca846d2969b0452018fdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.9.0 This release

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page