Skip to main content

Python 3 library for building Gopher clients and servers

Project description

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

Client

Pituophis can grab files and text from Gopher servers (both S/Gopher TLS and regular Gopher) through the Request.get() and get() functions.

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(host='gopher.floodgap.com', port=70, path='/').text()
pituophis.get(host='gopher.floodgap.com', port=70, path='/gopher/proxy').text()
pituophis.get(host='khzae.net', port=105, path='/', tls=True).text() # TLS!
pituophis.get('gophers://khzae.net:105/1/').text() # gophers:// URLs!

Getting a menu, parsed:

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

Using search services:

pituophis.get('gopher://gopher.floodgap.com:70/7/v2/vs?toast').text()
pituophis.get(host='gopher.floodgap.com', port=70, path='/v2/vs', query='toast').text()

Downloading a binary:

pituophis.get('gopher://gopher.floodgap.com:70/9/gopher/clients/win/hgopher2_3.zip').binary
pituophis.get(host='gopher.floodgap.com', port=70, path='/gopher/clients/win/hgopher2_3.zip').binary

Requests can also be created and worked with directly:

import pituophis
req = pituophis.Request()
req.host = 'gopher.floodgap.com'  # set to 127.0.0.1 by default
req.port = 70  # set to 70 as default, as per tradition
req.type = '7'  # set to 9 by default, purely for client usage
req.path = '/v2/vs'  # set to '/' by default
req.query = 'food'  # set to '' (nothing) by default
req.tls = False  # set to False by default
print('Getting', req.url())
rsp = req.get()
print(rsp.text())

They can also be created from a URL:

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

Server

Default Handler

Pituophis now lets you serve a directory. Serving gophermaps, directories, and files is supported out of the box.

server_def

Custom Handler

Pituophis also lets you write a custom handler for Gopher requests.

server

Project details


Download files

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

Source Distribution

Pituophis-0.99.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

Pituophis-0.99-py3.7.egg (15.9 kB view details)

Uploaded Egg

File details

Details for the file Pituophis-0.99.tar.gz.

File metadata

  • Download URL: Pituophis-0.99.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for Pituophis-0.99.tar.gz
Algorithm Hash digest
SHA256 f9f8f45a00aaeba4e2b85a1c98e54f05a3c9ee1408117ffdc8c1ab6bbb130c9e
MD5 86f05f2d058d0eecbba28ea60154c121
BLAKE2b-256 62bb1ef46379d80ebbe6bc0ee87a84c4c3bd9fb97a14d3b022fbe5a8c2d3d66c

See more details on using hashes here.

File details

Details for the file Pituophis-0.99-py3.7.egg.

File metadata

  • Download URL: Pituophis-0.99-py3.7.egg
  • Upload date:
  • Size: 15.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for Pituophis-0.99-py3.7.egg
Algorithm Hash digest
SHA256 bdff31ad22739acb894bdd35e4d1af48594c67c0f3c1482c3b8eed73e46b5b7a
MD5 ac4a1f6d34bbc2076c06ca5a213dec6f
BLAKE2b-256 ad83692bfa41b4d8db18a5530f8de4c50177ca851a4c791e76ae06ca1c3f0302

See more details on using hashes here.

Supported by

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