chore: dependency management

master
Simon de Vlieger 1 month ago
parent 2b79a28d9f
commit 5c0a3ce40e
Signed by: supakeen
GPG Key ID: D6C290547A1167B2

55
poetry.lock generated

@ -90,7 +90,7 @@ files = [
name = "click"
version = "8.1.3"
description = "Composable command line interface toolkit"
category = "main"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
@ -105,7 +105,7 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""}
name = "colorama"
version = "0.4.6"
description = "Cross-platform colored terminal text."
category = "main"
category = "dev"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
files = [
@ -240,14 +240,14 @@ testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "p
[[package]]
name = "identify"
version = "2.5.22"
version = "2.5.23"
description = "File identification library for Python"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "identify-2.5.22-py2.py3-none-any.whl", hash = "sha256:f0faad595a4687053669c112004178149f6c326db71ee999ae4636685753ad2f"},
{file = "identify-2.5.22.tar.gz", hash = "sha256:f7a93d6cf98e29bd07663c60728e7a4057615068d7a639d132dc883b2d54d31e"},
{file = "identify-2.5.23-py2.py3-none-any.whl", hash = "sha256:17d9351c028a781456965e781ed2a435755cac655df1ebd930f7186b54399312"},
{file = "identify-2.5.23.tar.gz", hash = "sha256:50b01b9d5f73c6b53e5fa2caf9f543d3e657a9d0bbdeb203ebb8d45960ba7433"},
]
[package.extras]
@ -443,19 +443,19 @@ files = [
[[package]]
name = "platformdirs"
version = "3.2.0"
version = "3.4.0"
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "platformdirs-3.2.0-py3-none-any.whl", hash = "sha256:ebe11c0d7a805086e99506aa331612429a72ca7cd52a1f0d277dc4adc20cb10e"},
{file = "platformdirs-3.2.0.tar.gz", hash = "sha256:d5b638ca397f25f979350ff789db335903d7ea010ab28903f57b27e1b16c2b08"},
{file = "platformdirs-3.4.0-py3-none-any.whl", hash = "sha256:01437886022decaf285d8972f9526397bfae2ac55480ed372ed6d9eca048870a"},
{file = "platformdirs-3.4.0.tar.gz", hash = "sha256:a5e1536e5ea4b1c238a1364da17ff2993d5bd28e15600c2c8224008aff6bbcad"},
]
[package.extras]
docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"]
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"]
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
[[package]]
name = "pluggy"
@ -694,47 +694,26 @@ files = [
[[package]]
name = "tomlkit"
version = "0.11.7"
version = "0.11.8"
description = "Style preserving TOML library"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "tomlkit-0.11.7-py3-none-any.whl", hash = "sha256:5325463a7da2ef0c6bbfefb62a3dc883aebe679984709aee32a317907d0a8d3c"},
{file = "tomlkit-0.11.7.tar.gz", hash = "sha256:f392ef70ad87a672f02519f99967d28a4d3047133e2d1df936511465fbb3791d"},
]
[[package]]
name = "tornado"
version = "6.3.1"
description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed."
category = "main"
optional = false
python-versions = ">= 3.8"
files = [
{file = "tornado-6.3.1-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:db181eb3df8738613ff0a26f49e1b394aade05034b01200a63e9662f347d4415"},
{file = "tornado-6.3.1-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:b4e7b956f9b5e6f9feb643ea04f07e7c6b49301e03e0023eedb01fa8cf52f579"},
{file = "tornado-6.3.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9661aa8bc0e9d83d757cd95b6f6d1ece8ca9fd1ccdd34db2de381e25bf818233"},
{file = "tornado-6.3.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:81c17e0cc396908a5e25dc8e9c5e4936e6dfd544c9290be48bd054c79bcad51e"},
{file = "tornado-6.3.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a27a1cfa9997923f80bdd962b3aab048ac486ad8cfb2f237964f8ab7f7eb824b"},
{file = "tornado-6.3.1-cp38-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:d7117f3c7ba5d05813b17a1f04efc8e108a1b811ccfddd9134cc68553c414864"},
{file = "tornado-6.3.1-cp38-abi3-musllinux_1_1_i686.whl", hash = "sha256:ffdce65a281fd708da5a9def3bfb8f364766847fa7ed806821a69094c9629e8a"},
{file = "tornado-6.3.1-cp38-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:90f569a35a8ec19bde53aa596952071f445da678ec8596af763b9b9ce07605e6"},
{file = "tornado-6.3.1-cp38-abi3-win32.whl", hash = "sha256:3455133b9ff262fd0a75630af0a8ee13564f25fb4fd3d9ce239b8a7d3d027bf8"},
{file = "tornado-6.3.1-cp38-abi3-win_amd64.whl", hash = "sha256:1285f0691143f7ab97150831455d4db17a267b59649f7bd9700282cba3d5e771"},
{file = "tornado-6.3.1.tar.gz", hash = "sha256:5e2f49ad371595957c50e42dd7e5c14d64a6843a3cf27352b69c706d1b5918af"},
{file = "tomlkit-0.11.8-py3-none-any.whl", hash = "sha256:8c726c4c202bdb148667835f68d68780b9a003a9ec34167b6c673b38eff2a171"},
{file = "tomlkit-0.11.8.tar.gz", hash = "sha256:9330fc7faa1db67b541b28e62018c17d20be733177d290a13b24c62d1614e0c3"},
]
[[package]]
name = "tox"
version = "4.5.0"
version = "4.5.1"
description = "tox is a generic virtualenv management and test command line tool"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "tox-4.5.0-py3-none-any.whl", hash = "sha256:dae5823ac7b31514d33c6aabc332f19187d7842d1e07d88f00dd329e79a1737d"},
{file = "tox-4.5.0.tar.gz", hash = "sha256:231382d5ecda16878c572a252158219a5d43936fd49da92a0d811ec0debfef87"},
{file = "tox-4.5.1-py3-none-any.whl", hash = "sha256:d25a2e6cb261adc489604fafd76cd689efeadfa79709965e965668d6d3f63046"},
{file = "tox-4.5.1.tar.gz", hash = "sha256:5a2eac5fb816779dfdf5cb00fecbc27eb0524e4626626bb1de84747b24cacc56"},
]
[package.dependencies]
@ -789,4 +768,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "coverage-enable-subprocess
[metadata]
lock-version = "2.0"
python-versions = ">=3.9,<4"
content-hash = "d0e6cba1a5d43e903ce0a244580f44d2db587a2d58ad250c2a09abbaa75a0482"
content-hash = "c4614660865fed5dd2bc3a1cb6867e3483c7e28caf39cd1d81fff45f98e95823"

@ -18,8 +18,6 @@ packages = [
[tool.poetry.dependencies]
python = ">=3.9,<4"
tornado = "^6.0"
click = "^8.0"
python-magic = "^0.4.27"
[tool.poetry.dev-dependencies]

@ -1,97 +0,0 @@
import logging
from typing import Tuple, Any
import tornado.tcpserver
import tornado.iostream
import gb.protocol
import gb.mode
log = logging.getLogger(__name__)
class GopherServer(tornado.tcpserver.TCPServer):
"""Generic tornado TCPServer which speaks the Gopher protocol. The Gopher
protocol is defined in RFC 1436:
https://tools.ietf.org/html/rfc1436."""
# XXX TODO has to come from somewhere!
encoding: str
mode: gb.mode.Mode
async def handle_stream(
self, stream: tornado.iostream.IOStream, address: Tuple[Any, ...]
) -> None:
"""A new incoming connection. We wait silently until the client sends
a selector through after which we clean and parse that selector."""
log.debug("Accepted connection from %s", address)
while True:
try:
# clean this up, split on \n but clean both
selector_raw = await stream.read_until(
gb.protocol.crlf.encode(self.encoding),
)
selector_dec = selector_raw.decode(self.encoding)
# clean this up, split on \n but clean both with \r
selector_dec = gb.protocol.clean_selector(selector_dec)
# If this is not a valid selector we immediately terminate
# the connection
if not gb.protocol.is_valid_selector(selector_dec):
log.warn(
"%s requested invalid selector %r, terminating.",
address,
selector_dec,
)
await self.close_stream(stream)
break
log.info("%s requested %r", address, selector_dec)
# Use our mode specific lookup to get our response
resp_raw = await self.lookup(stream, selector_dec)
resp_enc = resp_raw.encode(self.encoding)
# Write and exit the connection
await stream.write(resp_enc)
await self.close_stream(stream)
except ValueError:
log.warning("Looking up selector %r failed", selector_dec)
await self.close_stream(stream)
break
except tornado.iostream.StreamClosedError:
log.debug("Lost connection from %s", address)
break
async def close_stream(self, stream: tornado.iostream.IOStream) -> None:
"""Gopher connections are closed by writing a . on a single line then
closing the underlying transport."""
await stream.write(gb.protocol.eof.encode(self.encoding))
await stream.write(gb.protocol.crlf.encode(self.encoding))
stream.close()
async def lookup(self, stream: tornado.iostream.IOStream, data: str) -> str:
"""Lookup a selector on our mode."""
return self.mode.lookup(data)
class ImplicitGopherServer(GopherServer):
"""The implicit gopher server serves files from a given path recursively
while auto generating indexes for directories. If magic is enabled then
the mode will auto-guess filetypes."""
def __init__(
self, path: str, host: str, port: int, magic: bool, encoding: str
) -> None:
super().__init__()
log.info("Starting ImplicitGopherServer with path %s", path)
self.encoding = encoding
self.mode = gb.mode.ImplicitMode(path, host, port, magic)
Loading…
Cancel
Save