Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Parse and serialise HTTP structured field values
Basic Info
Statistics
- Stars: 13
- Watchers: 4
- Forks: 0
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
HTTP Structured Field Values in Python
This Package is DEPRECATED
See the http-sf package for a replacement. This package will only be updated for security issues, and may be yanked in the future.
Introduction
This is a Python 3 library implementing parsing and serialisation of HTTP Structured Fields.
The library's initial purpose is to prove the algorithms in the specification; as a result, it is not at all optimised. It tracks the specification closely, but since it is not yet an RFC, may change at any time.
Currently, this implements draft-ietf-httpbis-sfbis-03.
Python API
There are three top-level types for Structured Field Values; Dictionary, List and Item. After instantiation, each can be used to parse a string HTTP header field value by calling .parse():
~~~ python
from httpsfv import List mylist = List() my_list.parse(b"foo; a=1, bar; b=2") ~~~
Note that .parse() takes a bytes-like object. If you want to parse a string, please .encode() it first.
Members of Lists and Dictionaries are available by normal Pythonic list and dictionary methods, respectively:
~~~ python
mylist [<httpsfv.item.Item object at 0x106d25190>,
] mylist[0] <httpsfv.item.Item object at 0x106d25190> ~~~
Items (whether top-level or inside a list or dictionary value) can have their values accessed with the .value property:
~~~ python
my_list[0].value 'foo' ~~~
Parameters on Items (and Inner Lists) can be accessed using the .params property, which is a dictionary:
~~~ python
my_list[0].params['a'] 1 ~~~
Note that Tokens and Strings both evaluate as Python strings, but Tokens have a different class:
~~~ python
type(mylist[0].value) <class 'httpsfv.token.Token'> ~~~
That means that you need to create Tokens explicitly:
~~~ python
from httpsfv import Token mylist.append(Token('bar')) my_list[-1] 'bar' ~~~
Likewise, Display Strings are represented using DisplayString objects; Dates as datetime.datetime objects.
If you compare two Items, they'll be considered to be equivalent if their values match, even when their parameters are different:
~~~ python
Token('foo') in mylist # note that mylist's 'foo' has a parameter True my_list.count(Token("foo")) 1 ~~~
Inner Lists can be added by passing a list:
~~~ python
mylist.append(['anotherthing', 'andanother']) print(mylist) foo;a=1, bar;b=2, bar, ("anotherthing" "andanother") my_list[-1][-1].params['a'] = True ~~~
Dictionaries, Lists, and Items can be instantiated with a value:
~~~ python
from httpsfv import Dictionary mydictionary = Dictionary({'a': '1', 'b': 2, 'c': Token('foo')}) mydictionary {'a': <httpsfv.item.Item object at 0x106a94c40>, 'b':
, 'c': } ~~~
Once instantiated, parameters can then be accessed:
~~~ python
my_dictionary['b'].params['1'] = 2.0 ~~~
Finally, to serialise a field value, just evaluate it as a string:
~~~ python
print(my_dictionary) a=1, b=2;b1=2.0, c=foo ~~~
Command Line Use
You can validate and examine the data model of a field value by calling the library on the command line, using -d, -l and -i to denote dictionaries, lists or items respectively; e.g.,
~~~ example
python3 -m httpsfv -i "foo;bar=baz" [ { "type": "token", "value": "foo" }, { "bar": { "_type": "token", "value": "baz" } } ] ~~~
or:
~~~ example
python3 -m http_sfv -i "foo;&bar=baz" FAIL: Key does not begin with lcalpha or * at: &bar=baz ~~~
Note that if successful, the output is in the JSON format used by the test suite.
Owner
- Name: Mark Nottingham
- Login: mnot
- Kind: user
- Location: Prahran, Australia
- Website: https://www.mnot.net/
- Repositories: 53
- Profile: https://github.com/mnot
I work on HTTP specifications and implementations.
GitHub Events
Total
- Delete event: 2
- Push event: 1
- Pull request event: 2
- Create event: 2
Last Year
- Delete event: 2
- Push event: 1
- Pull request event: 2
- Create event: 2
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Mark Nottingham | m****t@m****t | 244 |
| dependabot[bot] | 4****] | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 6
- Total pull requests: 6
- Average time to close issues: 6 months
- Average time to close pull requests: 3 days
- Total issue authors: 6
- Total pull request authors: 2
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 2
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mnot (1)
- ioggstream (1)
- martinthomson (1)
- kislyuk (1)
- jkhales (1)
- bortzmeyer (1)
Pull Request Authors
- mnot (4)
- dependabot[bot] (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 25,828 last-month
- Total dependent packages: 2
- Total dependent repositories: 3
- Total versions: 14
- Total maintainers: 1
pypi.org: http-sfv
Parse and serialise HTTP Structured Field Values
- Homepage: https://github.com/mnot/http_sfv
- Documentation: https://http-sfv.readthedocs.io/
- License: MIT License
-
Latest release: 0.9.9
published about 2 years ago
Rankings
Maintainers (1)
Dependencies
- black *
- build *
- mypy >=0.770
- pylint >=2.4.4
- twine >=3.1.1
- typing_extensions *
- actions/checkout v4 composite
- actions/setup-python v5 composite