wuttasync.cli.base
¶
wutta import-csv
command
- class wuttasync.cli.base.ImportCommandHandler(config, import_handler=None)[source]¶
This is the handler responsible for import/export command line runs.
Normally, the command (actually subcommand) logic will create this handler and call its
run()
method.This handler does not know how to import/export data, but it knows how to make its
import_handler
do it.- Parameters:
import_handler –
During construction, caller can specify the
import_handler
as any of:import handler instance
import handler factory (e.g. class)
import handler spec (cf.
load_object()
)
For example:
handler = ImportCommandHandler( config, import_handler='wuttasync.importing.csv:FromCsvToWutta')
- import_handler = None¶
Reference to the import handler instance, which is to be invoked when command runs. See also
run()
.
- list_models(params)[source]¶
Query the
import_handler
’s supported target models and print the info to stdout.This is what happens when command line has
--list-models
.
- run(params, progress=None)[source]¶
Run the import/export job(s) based on command line params.
This mostly just calls
process_data()
for theimport_handler
.Unless
--list-models
was specified on the command line in which case we dolist_models()
instead.- Parameters:
params – Dict of params from command line. This must include a
'models'
key, the rest are optional.progress – Optional progress indicator factory.
- wuttasync.cli.base.file_import_command(fn)[source]¶
Decorator for import/export commands which require input file. Adds common params based on
file_import_command_template()
.To use this, it’s the same method as shown for
import_command()
except in this case you would use thefile_import_command
decorator.
- wuttasync.cli.base.file_import_command_template(input_file_path: ~pathlib.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x7f592cf8b6d0>] = None)[source]¶
Stub function to provide signature for import/export commands which require input file. Used with
file_import_command()
.
- wuttasync.cli.base.import_command(fn)[source]¶
Decorator for import/export commands. Adds common params based on
import_command_template()
.To use this, e.g. for
poser import-foo
command:from poser.cli import poser_typer from wuttasync.cli import import_command, ImportCommandHandler @poser_typer.command() @import_command def import_foo( ctx: typer.Context, **kwargs ): """ Import data from Foo API to Poser DB """ config = ctx.parent.wutta_config handler = ImportCommandHandler( config, import_handler='poser.importing.foo:FromFooToPoser') handler.run(ctx.params)
See also
ImportCommandHandler
.
- wuttasync.cli.base.import_command_template(models: ~typing.Annotated[~typing.List[str] | None, <typer.models.ArgumentInfo object at 0x7f592dc213d0>] = None, list_models: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7f592f534610>] = False, create: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7f592dc200d0>] = True, update: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7f592cf8a8d0>] = True, delete: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7f592cf8a9d0>] = False, fields: ~typing.Annotated[str, <typer.models.OptionInfo object at 0x7f592cf8aad0>] = None, excluded_fields: ~typing.Annotated[str, <typer.models.OptionInfo object at 0x7f592cf8ac50>] = None, keys: ~typing.Annotated[str, <typer.models.OptionInfo object at 0x7f592cf8add0>] = None, max_create: ~typing.Annotated[int, <typer.models.OptionInfo object at 0x7f592cf8af50>] = None, max_update: ~typing.Annotated[int, <typer.models.OptionInfo object at 0x7f592cf8b0d0>] = None, max_delete: ~typing.Annotated[int, <typer.models.OptionInfo object at 0x7f592cf8b250>] = None, max_total: ~typing.Annotated[int, <typer.models.OptionInfo object at 0x7f592cf8b3d0>] = None, dry_run: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7f592cf8b550>] = False)[source]¶
Stub function which provides a common param signature; used with
import_command()
.