formatting
This commit is contained in:
parent
412efe2aec
commit
a9593e83a2
|
@ -105,6 +105,7 @@ def setup(context: typer.Context):
|
||||||
@db_app.command()
|
@db_app.command()
|
||||||
def list(context: typer.Context):
|
def list(context: typer.Context):
|
||||||
from ttfrog.db.manager import db
|
from ttfrog.db.manager import db
|
||||||
|
|
||||||
print("\n".join(sorted(db.tables.keys())))
|
print("\n".join(sorted(db.tables.keys())))
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ def dump(context: typer.Context):
|
||||||
Dump tables (or the entire database) as a JSON blob.
|
Dump tables (or the entire database) as a JSON blob.
|
||||||
"""
|
"""
|
||||||
from ttfrog.db.manager import db
|
from ttfrog.db.manager import db
|
||||||
|
|
||||||
db.init()
|
db.init()
|
||||||
print(db.dump(context.args))
|
print(db.dump(context.args))
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ class BaseObject(_BaseObject):
|
||||||
"""
|
"""
|
||||||
Allows for iterating over Model objects' column names and values
|
Allows for iterating over Model objects' column names and values
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__abstract__ = True
|
__abstract__ = True
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
|
|
@ -10,7 +10,6 @@ from pyramid_sqlalchemy import Session, init_sqlalchemy
|
||||||
from pyramid_sqlalchemy import metadata as _metadata
|
from pyramid_sqlalchemy import metadata as _metadata
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
|
||||||
|
|
||||||
import ttfrog.db.schema
|
import ttfrog.db.schema
|
||||||
from ttfrog.path import database
|
from ttfrog.path import database
|
||||||
|
|
||||||
|
@ -20,7 +19,7 @@ assert ttfrog.db.schema
|
||||||
class AlchemyEncoder(json.JSONEncoder):
|
class AlchemyEncoder(json.JSONEncoder):
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
try:
|
try:
|
||||||
return getattr(obj, '__json__')()
|
return getattr(obj, "__json__")()
|
||||||
except (AttributeError, NotImplementedError): # pragma: no cover
|
except (AttributeError, NotImplementedError): # pragma: no cover
|
||||||
return super().default(obj)
|
return super().default(obj)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .character import *
|
from .character import *
|
||||||
from .classes import *
|
from .classes import *
|
||||||
from .property import *
|
|
||||||
from .log import *
|
from .log import *
|
||||||
|
from .property import *
|
||||||
|
|
|
@ -32,14 +32,18 @@ def db(monkeypatch):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def classes_factory(db):
|
def classes_factory(db):
|
||||||
load_fixture(db, "classes")
|
load_fixture(db, "classes")
|
||||||
|
|
||||||
def factory():
|
def factory():
|
||||||
return dict((rec.name, rec) for rec in db.session.query(schema.CharacterClass).all())
|
return dict((rec.name, rec) for rec in db.session.query(schema.CharacterClass).all())
|
||||||
|
|
||||||
return factory
|
return factory
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def ancestries_factory(db):
|
def ancestries_factory(db):
|
||||||
load_fixture(db, "ancestry")
|
load_fixture(db, "ancestry")
|
||||||
|
|
||||||
def factory():
|
def factory():
|
||||||
return dict((rec.name, rec) for rec in db.session.query(schema.Ancestry).all())
|
return dict((rec.name, rec) for rec in db.session.query(schema.Ancestry).all())
|
||||||
|
|
||||||
return factory
|
return factory
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from ttfrog.db import schema
|
from ttfrog.db import schema
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user