1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-26 21:14:19 +00:00

📔 Improve logging and documentation

This commit is contained in:
Steffo 2021-01-08 16:14:06 +01:00
parent 68f7025640
commit 59a12c196b
2 changed files with 18 additions and 9 deletions

View file

@ -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

View file

@ -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