Skip to content

API

Provides tools for working with Gopher maps.

GopherItem

GopherItem(line: str)

A class for holding an item in the Gopher map.

Parameters:

Name Type Description Default

line

str

The line of text from the Gopher map.

required

display_text property

display_text: str

The display text of the Gopher item.

host property

host: str

The host of the Gopher item.

port property

port: int

The port of the Gopher item.

raw property

raw: str

The raw text of the Gopher item.

selector property

selector: str

The selector of the Gopher item.

type property

type: ItemType

The type of the Gopher item.

__repr__

__repr__() -> str

Return a string representation of the Gopher item.

GopherMap

GopherMap(map_text: str)

A class for parsing and holding a Gopher map.

Parameters:

Name Type Description Default

map_text

str

The text of the Gopher map.

required

items cached property

items: tuple[GopherItem, ...]

The list of Gopher items in the map.

raw property

raw: str

The raw text of the Gopher map.

GopherMapError

Bases: Exception

Base exception for all errors raised by the GopherMap library.

ItemType

Bases: StrEnum

An enumeration for the different types of Gopher items.

AUDIO class-attribute instance-attribute

AUDIO = 's'

An audio file.

BINARY class-attribute instance-attribute

BINARY = '9'

A binary file.

BINHEX class-attribute instance-attribute

BINHEX = '4'

A BinHexed file.

CSO class-attribute instance-attribute

CSO = '2'

A CSO phone book.

DOCUMENT class-attribute instance-attribute

DOCUMENT = 'd'

A document file.

DOS_FILE class-attribute instance-attribute

DOS_FILE = '5'

A DOS file.

ERROR class-attribute instance-attribute

ERROR = '3'

An error message.

GIF class-attribute instance-attribute

GIF = 'g'

A GIF image.

HTML class-attribute instance-attribute

HTML = 'h'

An HTML file.

IMAGE class-attribute instance-attribute

IMAGE = 'I'

An image file.

INDEX_SEARCH = '7'

An index search.

INFO class-attribute instance-attribute

INFO = 'i'

An informational message.

MENU class-attribute instance-attribute

MENU = '1'

A menu.

PDF class-attribute instance-attribute

PDF = 'P'

A PDF file.

TELNET class-attribute instance-attribute

TELNET = '8'

A telnet session.

TEXT class-attribute instance-attribute

TEXT = '0'

A text file.

UNKNOWN class-attribute instance-attribute

UNKNOWN = 'unknown'

An unknown type.

UUENCODED class-attribute instance-attribute

UUENCODED = '6'

A uuencoded file.

XML class-attribute instance-attribute

XML = 'X'

An XML file.

mime_type property

mime_type: str

Get the MIME type for the item type.

Note

This is a best-effort mapping and may not be accurate for all item types.

NoFields

Bases: GopherMapError

Raised when a Gopher item has no fields.