~hedy/spartan-py

9da535413a66b2bf1757faec624410f5d91c8876 — Hedy Li 2 years ago 5fcce53 v0.2.9
modify __repr__ for Request and update readme
3 files changed, 8 insertions(+), 4 deletions(-)

M README.md
M pyproject.toml
M spartan/request.py
M README.md => README.md +6 -2
@@ 19,7 19,9 @@ Try it in the REPL:
>>> import spartan
>>> req = spartan.Request("spartan.mozz.us")
>>> req
<Request spartan.mozz.us:300 / 0>
Request(host='spartan.mozz.us', port=300, path='/') data-length=0
>>> print(res)
'spartan.mozz.us / 0'
>>> res = req.send()
>>> res
2 text/gemini


@@ 37,7 39,7 @@ pip3 install spartan-py
## API

- `Request(host: str, port: int = 300, path: str = "/", data: str = "")`
  - `.send() -> Response` - send the request
  - `send() -> Response` - send the request
  - `__repr__()`
  - `__str__()`
- `Response(socket)`


@@ 45,6 47,8 @@ pip3 install spartan-py
  - `close()` - close the socket
  - `.status` - status code
  - `.meta` - meta string for the status
  - `.file` - socket file
  - `.request` - the Request object for this response
  - `__repr__()`
  - `__str__()`
- `Status` - statuses

M pyproject.toml => pyproject.toml +1 -1
@@ 1,6 1,6 @@
[tool.poetry]
name = "spartan-py"
version = "0.2.8"
version = "0.2.9"
description = "Library for spartan protocol"
authors = ["Hedy Li <hedy@tilde.cafe>"]
packages = [

M spartan/request.py => spartan/request.py +1 -1
@@ 13,7 13,7 @@ class Request:
        self.data = data

    def __repr__(self):
        return f"<Request {self.host} (port {self.port}) {self.path} {len(self.data)}>"
        return f"Request(host='{self.host}', port={self.port}, path='{self.path}') data-length={len(self.data)}"

    def __str__(self):
        return f"{self.host} {self.path} {len(self.data)}"