gophermap - A simple library for parsing Gopher maps
gophermap is a small and simple library that provides code for parsing
Gopher responses.
Installation
gophermap is available from pypi
and can be installed with your package installer of choice.
With pip:
pip install gophermap
With uv:
uv add gophermap
Quick start
The library provides a single main parsing class called GopherMap. It is
initialised with a response from a Gopher server, and the items property
provides a list of GopherItem objects.
A very minimal parser might look like this:
import fileinput
from gophermap import GopherMap
def parse_input() -> None:
with fileinput.input() as gopher_map:
for gopher_item in GopherMap("".join(gopher_map)).items:
print(f"{gopher_item!r}")
The library contains a simple test command line tool, which can be accessed
either via the Python -m switch, or depending on your environment, via the
gophermap command. For example, given this content of a file called
gophermap:
iSome places to find me and more of my stuff null.host 1
i~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ null.host 0
i null.host 1
hFind me all over URL:https://davep.at/ tilde.team 70
hFind me in Geminispace URL:gemini://tilde.team/~davep/ tilde.team 70
hMy blog URL:https://blog.davep.org/ tilde.team 70
hfinger://plan.cat/davep URL:finger://plan.cat/davep tilde.team 70
hfinger://tilde.team/davep URL:finger://tilde.team/davep tilde.team 70
i null.host 1
iMy current projects null.host 1
i~~~~~~~~~~~~~~~~~~~ null.host 0
i null.host 1
h[Web] Rogallo - A Gemini/Gopher/Finger client for the terminal URL:https://rogallo.davep.dev/ tilde.team 70
h[Gemini] Rogallo - A Gemini/Gopher/Finger client for the terminal URL:gemini://tilde.team/~davep/rogallo/ tilde.team 70
.
The gophermap command (or python -m gophermap) would produce:
$ gophermap gophermap
GopherItem(type=<ItemType.INFO: 'i'>, display_text='Some places to find me and more of my stuff', selector='', host='null.host', port=1)
GopherItem(type=<ItemType.INFO: 'i'>, display_text='~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', selector='', host='null.host', port=0)
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='Find me all over', selector='URL:https://davep.at/', host='tilde.team', port=70)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='Find me in Geminispace', selector='URL:gemini://tilde.team/~davep/', host='tilde.team', port=70)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='My blog', selector='URL:https://blog.davep.org/', host='tilde.team', port=70)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='finger://plan.cat/davep', selector='URL:finger://plan.cat/davep', host='tilde.team', port=70)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='finger://tilde.team/davep', selector='URL:finger://tilde.team/davep', host='tilde.team', port=70)
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
GopherItem(type=<ItemType.INFO: 'i'>, display_text='My current projects', selector='', host='null.host', port=1)
GopherItem(type=<ItemType.INFO: 'i'>, display_text='~~~~~~~~~~~~~~~~~~~', selector='', host='null.host', port=0)
GopherItem(type=<ItemType.INFO: 'i'>, display_text='', selector='', host='null.host', port=1)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='[Web] Rogallo - A Gemini/Gopher/Finger client for the terminal', selector='URL:https://rogallo.davep.dev/', host='tilde.team', port=70)
GopherItem(type=<ItemType.HTML: 'h'>, display_text='[Gemini] Rogallo - A Gemini/Gopher/Finger client for the terminal', selector='URL:gemini://tilde.team/~davep/rogallo/', host='tilde.team', port=70)
See the main documentation for the full API.
Metadata
Release files for gophermap 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gophermap-1.1.0.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gophermap-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / gophermap-1.1.0.tar.gz
| Download URL | gophermap-1.1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
050f75d63a7bde70cd74a8acd23520584a84ed11a9426b9f701991988195d4b5
|
|
BLAKE2b-256 checksum How to use checksums |
72859372edf76d3f19ba23da9da0ceb1512216bde502b7a5cbf08450d02e725c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / gophermap-1.1.0-py3-none-any.whl
| Download URL | gophermap-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb2ba54344445711530c5b7b5ccac559f83ebc2c9403d02a61bd9b0246afa45a
|
|
BLAKE2b-256 checksum How to use checksums |
8263a26971d2c6731c400bdd60e216eb9da3a15e399e63b988af5e1a711d7cc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|