Skip to content

Commit c4b5d31

Browse files
committed
refactor: rename view.sg_nameto view.pulished_name and use "published" for views with SG DBs
Published makes a bit more sense.
1 parent d288200 commit c4b5d31

File tree

7 files changed

+25
-20
lines changed

7 files changed

+25
-20
lines changed

dataimporter/cli/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from dataimporter.cli.portal import portal_group
1111
from dataimporter.cli.utils import with_config, console
1212
from dataimporter.cli.view import view_group
13-
from dataimporter.importer import DataImporter, ViewDoesNotHaveDatabase
13+
from dataimporter.importer import DataImporter, ViewIsNotPublished
1414
from dataimporter.lib.config import Config
1515

1616

@@ -41,7 +41,7 @@ def get_status(config: Config):
4141

4242
try:
4343
database = importer.get_database(view)
44-
except ViewDoesNotHaveDatabase:
44+
except ViewIsNotPublished:
4545
console.log(Rule())
4646
continue
4747

dataimporter/emu/views/artefact.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class ArtefactView(View):
3535
This view populates the artefacts resource on the Data Portal.
3636
"""
3737

38-
def __init__(self, path: Path, store: Store, image_view: ImageView, sg_name: str):
39-
super().__init__(path, store, sg_name)
38+
def __init__(
39+
self, path: Path, store: Store, image_view: ImageView, published_name: str
40+
):
41+
super().__init__(path, store, published_name)
4042
self.image_link = make_link(self, MEDIA_ID_REF_FIELD, image_view, ID)
4143

4244
def is_member(self, record: SourceRecord) -> FilterResult:

dataimporter/emu/views/indexlot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def __init__(
4444
store: Store,
4545
image_view: ImageView,
4646
taxonomy_view: TaxonomyView,
47-
sg_name: str,
47+
published_name: str,
4848
):
49-
super().__init__(path, store, sg_name)
49+
super().__init__(path, store, published_name)
5050
self.image_link = make_link(self, MEDIA_ID_REF_FIELD, image_view, ID)
5151
self.taxonomy_link = make_link(self, TAXONOMY_ID_REF_FIELD, taxonomy_view, ID)
5252

dataimporter/emu/views/preparation.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ class PreparationView(View):
8787
This view populates the preparation resource on the Data Portal.
8888
"""
8989

90-
def __init__(self, path: Path, store: Store, specimen_view: View, sg_name: str):
91-
super().__init__(path, store, sg_name)
90+
def __init__(
91+
self, path: Path, store: Store, specimen_view: View, published_name: str
92+
):
93+
super().__init__(path, store, published_name)
9294
self.specimen_view = specimen_view
9395
self.voucher_spec_link = make_link(
9496
self, SPECIMEN_ID_REF_FIELD, specimen_view, ID

dataimporter/emu/views/specimen.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def __init__(
163163
taxonomy_view: TaxonomyView,
164164
gbif_view: GBIFView,
165165
mammal_part_view: MammalPartView,
166-
sg_name: str,
166+
published_name: str,
167167
):
168-
super().__init__(path, store, sg_name)
168+
super().__init__(path, store, published_name)
169169
self.image_link = make_link(self, MEDIA_ID_REF_FIELD, image_view, ID)
170170
self.taxonomy_link = make_link(self, TAXONOMY_ID_REF_FIELD, taxonomy_view, ID)
171171
self.gbif_link = make_link(

dataimporter/importer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, name: str):
4242
self.name = name
4343

4444

45-
class ViewDoesNotHaveDatabase(Exception):
45+
class ViewIsNotPublished(Exception):
4646
def __init__(self, view: View):
4747
super().__init__(f"View {view.name} does not have a Splitgill database")
4848
self.view = view.name
@@ -173,9 +173,9 @@ def get_database(self, view: Union[str, View]) -> SplitgillDatabase:
173173
"""
174174
if isinstance(view, str):
175175
view = self.get_view(view)
176-
if not view.has_database:
177-
raise ViewDoesNotHaveDatabase(view)
178-
return SplitgillDatabase(view.sg_name, self.client)
176+
if not view.is_published:
177+
raise ViewIsNotPublished(view)
178+
return SplitgillDatabase(view.published_name, self.client)
179179

180180
def queue_changes(self, records: Iterable[SourceRecord], store_name: str):
181181
"""

dataimporter/lib/view.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,29 @@ class View:
6161
- links from this view to other views
6262
"""
6363

64-
def __init__(self, path: Path, store: Store, sg_name: Optional[str] = None):
64+
def __init__(self, path: Path, store: Store, published_name: Optional[str] = None):
6565
"""
6666
:param path: the root path that all view related data should be stored under
6767
:param store: the Store object that backs this view
68-
:param sg_name: the name of the SplitgillDatabase this view populates
68+
:param published_name: the name of the SplitgillDatabase this view populates
6969
"""
7070
self.path = path
7171
self.store = store
72-
self.sg_name = sg_name
72+
self.published_name = published_name
7373
self.name = path.name
7474
self.changes = ChangeQueue(self.path / "changes")
7575
# a list of links which need to be updated when records in this view change
7676
self.dependants: List[Link] = []
7777

7878
@property
79-
def has_database(self) -> bool:
79+
def is_published(self) -> bool:
8080
"""
81-
Returns whether this view directly feeds a Splitgill database.
81+
Returns whether this view directly feeds a Splitgill database, i.e. is
82+
"published" to the Portal.
8283
8384
:return: True if a Splitgill database should exist for this view, False if not
8485
"""
85-
return self.sg_name is not None
86+
return self.published_name is not None
8687

8788
def add_dependant(self, link: "Link"):
8889
"""

0 commit comments

Comments
 (0)