spartan-py
Basic spartan protocol implementation as a python library.
import spartan
res = spartan.get("spartan://mozz.us/echo", "hi")
while True:
buf = res.read()
if not buf:
break
sys.stdout.buffer.write(buf)
res.close()
Try it in the REPL:
>>> import spartan
>>> req = spartan.Request("spartan.mozz.us")
>>> req
Request(host='spartan.mozz.us', port=300, path='/') data-length=0
>>> print(req)
'spartan.mozz.us / 0'
>>> res = req.send()
>>> res
2 text/gemini
>>> res.read()
[...]
>>> res.close()
install
pip3 install spartan-py
API
Request(host: str, port: int = 300, path: str = "/", data: str = "")send() -> Response- send the request__repr__()__str__()
Response(socket)read()close()- close the socket.status- status code.meta- meta string for the status.file- socket file.request- the Request object for this response__repr__()__str__()
Status- statusessuccess = 2redirect = 3client_error = 4server_error = 5
get(url: str, data: str = "") -> Response- if the query string part in the URL exists, data will be ignored.
TODO
- invalid url handling
- util functions like parsing meta and getting status type
- basic CLI usage
- async methods
Metadata
Release files for spartan-py 0.2.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spartan-py-0.2.10.tar.gz | 3.5 kB | Without provenance | Details for spartan-py-0.2.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spartan_py-0.2.10-py3-none-any.whl | Python 3 | none | any | Details for spartan_py-0.2.10-py3-none-any.whl |
Total release size: 7.9 kB
Release files / spartan-py-0.2.10.tar.gz
| Download URL | spartan-py-0.2.10.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dffa4cf944d67e34d8414a1e0d16a129393485e21c5244bba8ec1df258d75af1
|
|
BLAKE2b-256 checksum How to use checksums |
c5412ec6e92414cc9598a3cd5f237249ce34ed1347058008c3a5061a3500f219
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.7.3 Linux/4.19.0-14-amd64
|
Release files / spartan_py-0.2.10-py3-none-any.whl
| Download URL | spartan_py-0.2.10-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8bebd22aba0be4cb1a22d03af5d20225d6af4b904fcf2228795f92d3f40b7246
|
|
BLAKE2b-256 checksum How to use checksums |
145a21b9f6ff825868901a672b233f69ca958223eeb0bd1798ffb798da551811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.7.3 Linux/4.19.0-14-amd64
|
Security for spartan-py 0.2.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.