Compare commits
No commits in common. "7ee551d44607f49f4eda671bed7ba72cf0eb41b5" and "f43a0663413368a69df49621d4dd00e8dfd185f9" have entirely different histories.
7ee551d446
...
f43a066341
|
@ -28,7 +28,7 @@ requires-python = ">= 3.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"makefun",
|
"makefun",
|
||||||
"SQLAlchemy-Utils",
|
"SQLAlchemy-Utils",
|
||||||
"WuttJamaican[db]>=0.16.2",
|
"WuttJamaican[db]",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,22 +56,25 @@ def importer_command_template(
|
||||||
bool,
|
bool,
|
||||||
typer.Option(help="Allow existing target records to be deleted.")] = False,
|
typer.Option(help="Allow existing target records to be deleted.")] = False,
|
||||||
|
|
||||||
# fields
|
|
||||||
fields: Annotated[
|
|
||||||
str,
|
|
||||||
typer.Option('--fields',
|
|
||||||
help="List of fields to process. See also --exclude.")] = None,
|
|
||||||
excluded_fields: Annotated[
|
|
||||||
str,
|
|
||||||
typer.Option('--exclude',
|
|
||||||
help="List of fields *not* to process. See also --fields.")] = None,
|
|
||||||
|
|
||||||
# dry run?
|
# dry run?
|
||||||
dry_run: Annotated[
|
dry_run: Annotated[
|
||||||
bool,
|
bool,
|
||||||
typer.Option('--dry-run',
|
typer.Option('--dry-run',
|
||||||
help="Go through the motions, but rollback the transaction.")] = False,
|
help="Go through the motions, but rollback the transaction.")] = False,
|
||||||
|
|
||||||
|
# # fields
|
||||||
|
# fields: Annotated[
|
||||||
|
# str,
|
||||||
|
# typer.Option('--fields',
|
||||||
|
# help="List of fields to process. If specified, "
|
||||||
|
# "any field not listed is excluded regardless "
|
||||||
|
# "of --exclude.")] = None,
|
||||||
|
# exclude_fields: Annotated[
|
||||||
|
# str,
|
||||||
|
# typer.Option('--exclude',
|
||||||
|
# help="List of fields not to process. If "
|
||||||
|
# "specified, any field not listed is (not?) included "
|
||||||
|
# "based on app logic and/or --fields.")] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Stub function which provides a common param signature; used with
|
Stub function which provides a common param signature; used with
|
||||||
|
|
|
@ -82,14 +82,6 @@ class Importer:
|
||||||
overwrite this attribute directly, for dynamic fields. If so
|
overwrite this attribute directly, for dynamic fields. If so
|
||||||
then ``get_fields()`` will return the new value. And really,
|
then ``get_fields()`` will return the new value. And really,
|
||||||
it's probably just as safe to read this attribute directly too.
|
it's probably just as safe to read this attribute directly too.
|
||||||
|
|
||||||
.. attribute:: excluded_fields
|
|
||||||
|
|
||||||
This attribute will often not exist, but is mentioned here for
|
|
||||||
reference.
|
|
||||||
|
|
||||||
It may be specified via constructor param in which case each
|
|
||||||
field listed therein will be removed from :attr:`fields`.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
allow_create = True
|
allow_create = True
|
||||||
|
@ -191,18 +183,6 @@ class Importer:
|
||||||
self.supported_fields = self.get_supported_fields()
|
self.supported_fields = self.get_supported_fields()
|
||||||
self.fields = self.get_fields()
|
self.fields = self.get_fields()
|
||||||
|
|
||||||
# fields could be comma-delimited string from cli param
|
|
||||||
if isinstance(self.fields, str):
|
|
||||||
self.fields = self.config.parse_list(self.fields)
|
|
||||||
|
|
||||||
# discard any fields caller asked to exclude
|
|
||||||
excluded = getattr(self, 'excluded_fields', None)
|
|
||||||
if excluded:
|
|
||||||
if isinstance(excluded, str):
|
|
||||||
excluded = self.config.parse_list(excluded)
|
|
||||||
self.fields = [f for f in self.fields
|
|
||||||
if f not in excluded]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def orientation(self):
|
def orientation(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -36,20 +36,6 @@ class TestImporter(DataTestCase):
|
||||||
self.assertTrue(imp.delete)
|
self.assertTrue(imp.delete)
|
||||||
self.assertFalse(imp.dry_run)
|
self.assertFalse(imp.dry_run)
|
||||||
|
|
||||||
def test_constructor_fields(self):
|
|
||||||
model = self.app.model
|
|
||||||
|
|
||||||
# basic importer
|
|
||||||
imp = self.make_importer(model_class=model.Setting, fields='name')
|
|
||||||
self.assertEqual(imp.fields, ['name'])
|
|
||||||
|
|
||||||
def test_constructor_excluded_fields(self):
|
|
||||||
model = self.app.model
|
|
||||||
|
|
||||||
# basic importer
|
|
||||||
imp = self.make_importer(model_class=model.Setting, excluded_fields='value')
|
|
||||||
self.assertEqual(imp.fields, ['name'])
|
|
||||||
|
|
||||||
def test_get_model_title(self):
|
def test_get_model_title(self):
|
||||||
model = self.app.model
|
model = self.app.model
|
||||||
imp = self.make_importer(model_class=model.Setting)
|
imp = self.make_importer(model_class=model.Setting)
|
||||||
|
|
Loading…
Reference in a new issue