From 59a12c196b2cfa9b4b7ffb5afda3e3980ba64bae Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 8 Jan 2021 16:14:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=94=20Improve=20logging=20and=20docume?= =?UTF-8?q?ntation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- royalnet/engineer/bullet.py | 3 +++ royalnet/engineer/magazine.py | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/royalnet/engineer/bullet.py b/royalnet/engineer/bullet.py index be47e5db..c3e9aedf 100644 --- a/royalnet/engineer/bullet.py +++ b/royalnet/engineer/bullet.py @@ -12,6 +12,8 @@ it is available. - :data:`None` is returned, meaning that there is no data in that field (if a message is not a reply to anything, :meth:`Message.reply_to` will be :data:`None`. - The data is returned. + +To instantiate a new :class:`Bullet` from a bullet, you should use the methods of :attr:`.Bullet.mag`. """ from __future__ import annotations @@ -20,6 +22,7 @@ import royalnet.royaltyping as t import abc import datetime import sqlalchemy.orm +import io from . import exc diff --git a/royalnet/engineer/magazine.py b/royalnet/engineer/magazine.py index 3a40c1b4..52ee3838 100644 --- a/royalnet/engineer/magazine.py +++ b/royalnet/engineer/magazine.py @@ -1,6 +1,7 @@ # Module docstring """ -.. todo:: Document magazines. +Magazines are references to the bullet classes used by a specific frontend; they allow bullets to instance each other +without tying the instantiations to specific classes. """ # Special imports @@ -8,6 +9,7 @@ from __future__ import annotations import royalnet.royaltyping as t # External imports +import functools import logging # Internal imports @@ -30,20 +32,24 @@ class Magazine: _CHANNEL = bullet.Channel @property - def Bullet(self) -> bullet.Bullet: - return self._BULLET(mag=self) + def Bullet(self) -> functools.partial[bullet.Bullet]: + log.debug(f"Extracting Bullet from Magazine: {self._BULLET!r}") + return functools.partial(self._BULLET, mag=self) @property - def User(self) -> bullet.User: - return self._USER(mag=self) + def User(self) -> functools.partial[bullet.User]: + log.debug(f"Extracting User from Magazine: {self._USER!r}") + return functools.partial(self._USER, mag=self) @property - def Message(self) -> bullet.Message: - return self._MESSAGE(mag=self) + def Message(self) -> functools.partial[bullet.Message]: + log.debug(f"Extracting Message from Magazine: {self._MESSAGE!r}") + return functools.partial(self._MESSAGE, mag=self) @property - def Channel(self) -> bullet.Channel: - return self._CHANNEL(mag=self) + def Channel(self) -> functools.partial[bullet.Channel]: + log.debug(f"Extracting Channel from Magazine: {self._CHANNEL!r}") + return functools.partial(self._CHANNEL, mag=self) # Objects exported by this module