Skip to main content

Rfcparser is a Python tool that makes it easy to parse common RFC syntaxes. Rfcparser takes a raw string as input, parses, validates, and returns Python objects to simplify the processing of RFC syntaxes.

Project description

Rfcparser

Rfcparser is a Python tool that makes it easy to parse common RFC syntaxes. Rfcparser takes a raw string as input, parses, validates, and returns Python objects to simplify the processing of RFC syntaxes.

Installing

$ pip install rfcparser

or

$ git clone https://github.com/karosis88/rfcparser.git
$ pip install ./rfcparser

Usage

Examples and detailed instructions on how to use the Rfcparser library to parse RFC syntaxes.

In most cases, you will primarily use the 'core' module, which offers a convenient interface for parsing your raw input string

>>> from rfcparser import core

Rfcparser offers a specific class for each grammar, with a class name following the pattern of "PREFIX PARSER RFC-NUMBER"

Fortunately, most modern IDEs now offer autocompletion, which will assist you in locating the parser classes you need to use.

URI parsing

>>> uri = "https://login:password@127.0.0.1:1010/path?name=test#fr"
>>> parsed_uri = core.UriParser3986().parse(uri)

With Rfcparser, you now have access to a 'parsed_uri' that is not just a plain string, but rather a Python object. This makes it easier to work with the URI, and you don't need to worry about compatibility issues with other applications as the library parses syntaxes according to the latest RFC standards.

>>> parsed_uri.scheme
'https'
>>> parsed_uri.userinfo
'login:password'
>>> parsed_uri.ip
'127.0.0.1'
>>> parsed_uri.port
1010
>>> parsed_uri.path
'/path'
>>> parsed_uri.query
{'name': 'test'}
>>> parsed_uri.fragment
'fr'

Date-Time parser

>>> date_str = "Tue, 07-Feb-2023 13:20:04 GMT"
>>> parsed_date = core.DateParser6265().parse(date_str)
>>> type(parsed_date)
<class 'datetime.datetime'>
>>> parsed_date.day
7

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfcparser-0.0.8.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

rfcparser-0.0.8-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file rfcparser-0.0.8.tar.gz.

File metadata

  • Download URL: rfcparser-0.0.8.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.3

File hashes

Hashes for rfcparser-0.0.8.tar.gz
Algorithm Hash digest
SHA256 0c77179ae165216ecc1b706a89d698f30ba014e9676c4e33c08d57ad80d318d5
MD5 09b1a49bd55c5e187fc4fb56cd897177
BLAKE2b-256 d018a98308a9a8888dede2c6cc9ac28081a3de3e53de87aed26a4bb1f5ad2399

See more details on using hashes here.

File details

Details for the file rfcparser-0.0.8-py2.py3-none-any.whl.

File metadata

  • Download URL: rfcparser-0.0.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.3

File hashes

Hashes for rfcparser-0.0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 edc15af700fb889fd2a4624b24e05c2776ac1378d7b765b37b5e61ff48758324
MD5 ddffa4ea9f597a18d4f4e329e1db41ca
BLAKE2b-256 deff0b408826ca3af23908775ee17d3f7280a235cc73dc910fa9d5a297dad98e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page