mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
rename package
This commit is contained in:
parent
2f5cc3c6d1
commit
39d93cde7d
13 changed files with 17 additions and 17 deletions
34
fftcgtool.py
34
fftcgtool.py
|
@ -6,17 +6,17 @@ import zipfile
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
import fftcg
|
import fftcgtool
|
||||||
|
|
||||||
|
|
||||||
class LanguageParamType(click.ParamType):
|
class LanguageParamType(click.ParamType):
|
||||||
def convert(self, value, param, ctx) -> fftcg.Language:
|
def convert(self, value, param, ctx) -> fftcgtool.Language:
|
||||||
if isinstance(value, fftcg.Language):
|
if isinstance(value, fftcgtool.Language):
|
||||||
return value
|
return value
|
||||||
elif isinstance(value, str):
|
elif isinstance(value, str):
|
||||||
return fftcg.Language(value)
|
return fftcgtool.Language(value)
|
||||||
else:
|
else:
|
||||||
return fftcg.Language("")
|
return fftcgtool.Language("")
|
||||||
|
|
||||||
|
|
||||||
LANGUAGE = LanguageParamType()
|
LANGUAGE = LanguageParamType()
|
||||||
|
@ -102,14 +102,14 @@ def main(ctx, **kwargs) -> None:
|
||||||
# load the current carddb
|
# load the current carddb
|
||||||
if kwargs["db_url"] is not None:
|
if kwargs["db_url"] is not None:
|
||||||
try:
|
try:
|
||||||
fftcg.CardDB(kwargs["db_url"])
|
fftcgtool.CardDB(kwargs["db_url"])
|
||||||
|
|
||||||
except (ValueError, KeyError, zipfile.BadZipFile) as cause:
|
except (ValueError, KeyError, zipfile.BadZipFile) as cause:
|
||||||
logger.critical(f"Couldn't initialize CardDB: {cause}")
|
logger.critical(f"Couldn't initialize CardDB: {cause}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
fftcg.RWCardDB(kwargs["db_file"])
|
fftcgtool.RWCardDB(kwargs["db_file"])
|
||||||
|
|
||||||
|
|
||||||
@main.command()
|
@main.command()
|
||||||
|
@ -126,7 +126,7 @@ def main(ctx, **kwargs) -> None:
|
||||||
metavar="[OPUS-ID] ...",
|
metavar="[OPUS-ID] ...",
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def opuses(ctx, opus_ids, num_requests) -> list[fftcg.TTSDeck]:
|
def opuses(ctx, opus_ids, num_requests) -> list[fftcgtool.TTSDeck]:
|
||||||
"""
|
"""
|
||||||
Imports Opuses from the square API and creates its elemental decks as JSON files.
|
Imports Opuses from the square API and creates its elemental decks as JSON files.
|
||||||
|
|
||||||
|
@ -134,14 +134,14 @@ def opuses(ctx, opus_ids, num_requests) -> list[fftcg.TTSDeck]:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
language = ctx.obj["language"] or fftcg.Language("")
|
language = ctx.obj["language"] or fftcgtool.Language("")
|
||||||
|
|
||||||
carddb = fftcg.CardDB()
|
carddb = fftcgtool.CardDB()
|
||||||
decks: list[fftcg.TTSDeck] = []
|
decks: list[fftcgtool.TTSDeck] = []
|
||||||
for opus_id in opus_ids:
|
for opus_id in opus_ids:
|
||||||
# import an opus
|
# import an opus
|
||||||
opus = fftcg.Opus(opus_id, language)
|
opus = fftcgtool.Opus(opus_id, language)
|
||||||
book = fftcg.Book(opus, language, num_requests)
|
book = fftcgtool.Book(opus, language, num_requests)
|
||||||
book.save()
|
book.save()
|
||||||
|
|
||||||
carddb.update(opus)
|
carddb.update(opus)
|
||||||
|
@ -161,23 +161,23 @@ def opuses(ctx, opus_ids, num_requests) -> list[fftcg.TTSDeck]:
|
||||||
type=str,
|
type=str,
|
||||||
metavar="[DECK-ID] ...",
|
metavar="[DECK-ID] ...",
|
||||||
)
|
)
|
||||||
def ffdecks(deck_ids) -> list[fftcg.TTSDeck]:
|
def ffdecks(deck_ids) -> list[fftcgtool.TTSDeck]:
|
||||||
"""
|
"""
|
||||||
Imports Decks from the ffdecks.com API and creates it as a JSON file.
|
Imports Decks from the ffdecks.com API and creates it as a JSON file.
|
||||||
|
|
||||||
DECK_ID: each of the Decks to import
|
DECK_ID: each of the Decks to import
|
||||||
"""
|
"""
|
||||||
|
|
||||||
decks: list[fftcg.TTSDeck] = []
|
decks: list[fftcgtool.TTSDeck] = []
|
||||||
for deck_id in deck_ids:
|
for deck_id in deck_ids:
|
||||||
# import a deck
|
# import a deck
|
||||||
decks.append(fftcg.TTSDeck.from_ffdecks_deck(deck_id))
|
decks.append(fftcgtool.TTSDeck.from_ffdecks_deck(deck_id))
|
||||||
|
|
||||||
return decks
|
return decks
|
||||||
|
|
||||||
|
|
||||||
@main.result_callback()
|
@main.result_callback()
|
||||||
def finalize(decks: list[fftcg.TTSDeck], **kwargs):
|
def finalize(decks: list[fftcgtool.TTSDeck], **kwargs):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# decide what to do with the decks
|
# decide what to do with the decks
|
||||||
|
|
Loading…
Reference in a new issue