1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Remove some fixed todos

This commit is contained in:
Steffo 2020-01-31 16:56:38 +01:00
parent d8d338183c
commit de21892174
6 changed files with 24 additions and 22 deletions

View file

@ -23,7 +23,6 @@ class Matrix:
@property @property
def username(self): def username(self):
# TODO: check this regex
match = re.match("^@(.+):.+$", self.matrix_id) match = re.match("^@(.+):.+$", self.matrix_id)
result = match.group(1) result = match.group(1)
assert result is not None assert result is not None
@ -31,7 +30,6 @@ class Matrix:
@property @property
def homeserver(self): def homeserver(self):
# TODO: check this regex
match = re.match("^@.+:(.+)$", self.matrix_id) match = re.match("^@.+:(.+)$", self.matrix_id)
result = match.group(1) result = match.group(1)
assert result is not None assert result is not None

View file

@ -1,6 +1,6 @@
from typing import * from typing import *
import asyncio as aio import asyncio as aio
from .errors import UnsupportedError from .errors import *
if TYPE_CHECKING: if TYPE_CHECKING:
from .event import Event from .event import Event
from .command import Command from .command import Command
@ -34,20 +34,6 @@ class CommandInterface:
Example: Example:
A reference to a :class:`~royalnet.constellation.Constellation`.""" A reference to a :class:`~royalnet.constellation.Constellation`."""
@property
def alchemy(self) -> "Alchemy":
"""A shortcut for :attr:`.serf.alchemy`."""
return self.serf.alchemy
@property
def loop(self) -> aio.AbstractEventLoop:
"""A shortcut for :attr:`.serf.loop`."""
if self.serf:
return self.serf.loop
else:
# TODO
raise Exception("TODO")
def __init__(self, config: Dict[str, Any]): def __init__(self, config: Dict[str, Any]):
self.config: Dict[str, Any] = config self.config: Dict[str, Any] = config
"""The config section for the pack of the command.""" """The config section for the pack of the command."""
@ -56,6 +42,28 @@ class CommandInterface:
self.command: Optional[Command] = None self.command: Optional[Command] = None
self.event: Optional[Event] = None self.event: Optional[Event] = None
@property
def alchemy(self) -> "Alchemy":
"""A shortcut for :attr:`.serf.alchemy`."""
return self.serf.alchemy
@property
def table(self) -> "Callable":
"""A shortcut for :func:`.serf.alchemy.get`.
Raises:
UnsupportedError: if :attr:`.alchemy` is :const:`None`."""
if self.alchemy is None:
raise UnsupportedError("'alchemy' is not enabled on this Royalnet instance")
return self.alchemy.get
@property
def loop(self) -> aio.AbstractEventLoop:
"""A shortcut for :attr:`.serf.loop`."""
if self.serf:
return self.serf.loop
raise UnsupportedError("This command is not being run in a serf.")
async def call_herald_event(self, destination: str, event_name: str, **kwargs) -> dict: async def call_herald_event(self, destination: str, event_name: str, **kwargs) -> dict:
"""Call an event function on a different :class:`~royalnet.serf.Serf`. """Call an event function on a different :class:`~royalnet.serf.Serf`.

View file

@ -316,8 +316,6 @@ class Constellation:
log.info(f"Running Constellation on https://{self.address}:{self.port}/...") log.info(f"Running Constellation on https://{self.address}:{self.port}/...")
loop: aio.AbstractEventLoop = aio.get_event_loop() loop: aio.AbstractEventLoop = aio.get_event_loop()
self.running = True self.running = True
# TODO: figure out how to run the correct event loop
# loop.create_task(self.herald.run())
try: try:
uvicorn.run(self.starlette, host=self.address, port=self.port, log_config=UVICORN_LOGGING_CONFIG) uvicorn.run(self.starlette, host=self.address, port=self.port, log_config=UVICORN_LOGGING_CONFIG)
finally: finally:

View file

@ -26,7 +26,6 @@ class Package:
source_conv_id: The conversation id of the node that created this package. source_conv_id: The conversation id of the node that created this package.
Akin to the sequence number on IP packets. Akin to the sequence number on IP packets.
destination_conv_id: The conversation id of the node that this Package is a reply to.""" destination_conv_id: The conversation id of the node that this Package is a reply to."""
# TODO: something is not right in these type hints. Check them.
self.data: dict = data self.data: dict = data
self.source: str = source self.source: str = source
self.source_conv_id: str = source_conv_id or str(uuid.uuid4()) self.source_conv_id: str = source_conv_id or str(uuid.uuid4())

View file

@ -102,7 +102,7 @@ class Server:
log.debug(f"Received package: {package}") log.debug(f"Received package: {package}")
# Check if the package destination is the server itself. # Check if the package destination is the server itself.
if package.destination == "<server>": if package.destination == "<server>":
# TODO: do stuff # Do... nothing for now?
pass pass
# Otherwise, route the package to its destination # Otherwise, route the package to its destination
# noinspection PyAsyncCall # noinspection PyAsyncCall

View file

@ -20,7 +20,6 @@ class VoicePlayer:
self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
else: else:
self.loop = loop self.loop = loop
# FIXME: this looks like spaghetti
self._playback_ended_event: threading.Event = threading.Event() self._playback_ended_event: threading.Event = threading.Event()
async def connect(self, channel: "discord.VoiceChannel") -> "discord.VoiceClient": async def connect(self, channel: "discord.VoiceChannel") -> "discord.VoiceClient":