MCPcopy Index your code
hub / github.com/dotcomboom/Pituophis

github.com/dotcomboom/Pituophis @v1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1 ↗ · + Follow
36 symbols 123 edges 14 files 19 documented · 53%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Pituophis

Documentation Status PyPI version PyPI license

Python 3 library for building Gopher clients and servers

Pituophis, at the moment, requires nine modules: os, re, sockets, asyncio, ssl, mimetypes, glob, and urllib, which are standard in most Python 3.7 installations, and natsort. Pituophis can simply be loaded as a module like this:

import pituophis

Server

Pituophis can act as a powerful Gopher server, with full Bucktooth-style gophermap and globbing support. Scripting is also supported through alt handlers (used in the event of a 404) or fully custom handlers (replaces Pituophis' handler entirely).

The simplest method of getting a server up and running is with the pituophis.serve() function. See the examples and docs for more information. If you'd like to see a server built with Pituophis that can search an index, try Gophew.

server_def

Client

Pituophis can also grab files and parse menus from Gopher servers. Simple fetching is done with Request().get() and get(), and Request().stream() can be used for lower-level access as a BufferedReader. The get functions return a Response type. See the docs for more information.

TreeGopher

An interactive demo of Pituophis' client features is provided in the form of TreeGopher, a graphical Gopher client in ~200 lines of code. It uses Pituophis, PySimpleGUI, and Pyperclip. It can browse Gopher in a hierarchical structure (similarly to WSGopher32, Cyberdog, and Little Gopher Client), read text files, download and save binary files (writing in chunks using Request().stream(), and running on another thread), recognize URL: links and use search services.

Examples

Getting menus and files as plain text:

pituophis.get('gopher.floodgap.com').text()
pituophis.get('gopher://gopher.floodgap.com/1/').text()
pituophis.get('gopher://gopher.floodgap.com:70/0/gopher/proxy').text()
pituophis.get('gophers://khzae.net:105/1/').text() # gophers:// URL support

Getting a menu, parsed:

menu = pituophis.get('gopher.floodgap.com').menu()
for item in menu:
    print(item.type)
    print(item.text)
    print(item.path)
    print(item.host)
    print(item.port)

Using search services:

pituophis.get('gopher://gopher.floodgap.com:70/7/v2/vs%09toast').text()

Downloading a binary:

pituophis.get('gopher://gopher.floodgap.com:70/9/gopher/clients/win/hgopher2_3.zip').binary

Requests can also be created from a URL:

import pituophis
req = pituophis.parse_url('gopher://gopher.floodgap.com/7/v2/vs%09food')
print('Getting', req.url())
rsp = req.get()
print(rsp.text())

Core symbols most depended-on inside this repo

Shape

Function 20
Method 12
Class 4

Languages

Python100%

Modules by API surface

pituophis/__init__.py23 symbols
TreeGopher.py4 symbols
examples/server_cgi_tls.py3 symbols
examples/catenifer.py2 symbols
examples/server_custom_reroute.py1 symbols
examples/server_custom_comments.py1 symbols
examples/server_custom.py1 symbols
examples/server_cgi.py1 symbols

For agents

$ claude mcp add Pituophis \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page