Skip to main content

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.

Download files

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

Source Distribution

gophermap-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gophermap-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file gophermap-0.1.1.tar.gz.

File metadata

  • Download URL: gophermap-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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}

File hashes

Hashes for gophermap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d1d57bbcc51f0c6ab59c50f931ebef024a26a14d984d91a986d4dbd36411f615
MD5 417a652cb3c376282356307b687ec416
BLAKE2b-256 19f05c81e50c0a17b2d02b63894f7d5ef4b65d90fadcce110ad383e4146dd2d9

See more details on using hashes here.

File details

Details for the file gophermap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gophermap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","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}

File hashes

Hashes for gophermap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7df2df086c8035689c5e525de31ca54314f8675efab3ea30007620e14a52304c
MD5 be28507c2d31d77c0eb8bdc6499a18a2
BLAKE2b-256 ed61f15bda3d466fd6e6b8eab40f8597f81d5e3c3874adb2f0215cbcf1bb0a75

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.0

2 files

0.2.0

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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