mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 03:24:20 +00:00
🧹 Clean up code
This commit is contained in:
parent
ae5b4cdbde
commit
84f6928207
7 changed files with 19 additions and 8 deletions
|
@ -1,4 +1,3 @@
|
|||
from ..typing import *
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,13 @@ class Makeable:
|
|||
|
||||
@classmethod
|
||||
def make(cls: Type[T], session: o.session.Session, **kwargs) -> T:
|
||||
"""Find the item with the specified name, or create it if it doesn't exist."""
|
||||
"""
|
||||
Find the item with the specified name, or create it if it doesn't exist.
|
||||
|
||||
:param session: The session to be used in the query and creation.
|
||||
:param kwargs: Arguments to use in the filter_by clause and in the item constructor.
|
||||
:return: The retrieved or created item.
|
||||
"""
|
||||
# Find the item
|
||||
item = session.query(cls).filter_by(**kwargs).one_or_none()
|
||||
# Create the item
|
||||
|
@ -25,7 +31,12 @@ class Makeable:
|
|||
|
||||
@classmethod
|
||||
def unmake(cls: Type[T], session: o.session.Session, **kwargs) -> None:
|
||||
"""Find the item with the specified name, and delete it if it exists."""
|
||||
"""
|
||||
Find the item with the specified name, and delete it if it exists.
|
||||
|
||||
:param session: The session to be used in the query and creation.
|
||||
:param kwargs: Arguments to use in the filter_by clause and in the item constructor.
|
||||
"""
|
||||
# Find the item
|
||||
item = session.query(cls).filter_by(**kwargs).one_or_none()
|
||||
# Delete the item
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
class ColRepr:
|
||||
"""A mixin that can be added to a declared class to display all table columns in the __repr__."""
|
||||
"""
|
||||
A mixin that can be added to a declared class to display all table columns in the __repr__.
|
||||
"""
|
||||
|
||||
def __repr__(self):
|
||||
columns = [c.name for c in self.__class__.__table__.columns]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from ..errors import RoyalnetException
|
||||
from ..exc import RoyalnetException
|
||||
|
||||
|
||||
class CampaignsError(RoyalnetException):
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from royalnet.typing import *
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import toml
|
||||
import json
|
||||
|
@ -36,7 +35,7 @@ class Scroll:
|
|||
|
||||
@classmethod
|
||||
def from_file(cls, namespace: str, file_path: os.PathLike):
|
||||
file, ext = os.path.splitext(file_path)
|
||||
_, ext = os.path.splitext(file_path)
|
||||
lext = ext.lower()
|
||||
|
||||
with open(file_path) as file:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from ..errors import RoyalnetException
|
||||
from ..exc import RoyalnetException
|
||||
|
||||
|
||||
class ScrollsException(RoyalnetException):
|
||||
|
|
Loading…
Reference in a new issue