Improve some attribute/method names
This commit is contained in:
parent
1b69b19ec3
commit
c7bb3e3c11
4 changed files with 18 additions and 16 deletions
|
|
@ -15,12 +15,12 @@ class OFMThing(lt.Thing):
|
|||
|
||||
_data_dir: Optional[str] = None
|
||||
|
||||
_show_in_gallery: bool = False
|
||||
_show_data_in_gallery: bool = False
|
||||
|
||||
@property
|
||||
def show_in_gallery(self) -> bool:
|
||||
def show_data_in_gallery(self) -> bool:
|
||||
"""Whether to show in the Gallery."""
|
||||
return self._show_in_gallery
|
||||
return self._show_data_in_gallery
|
||||
|
||||
def __enter__(self) -> Self:
|
||||
"""Set the data directory when the Thing is entered."""
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ class GalleryCompatibleThing(Protocol):
|
|||
_thing_server_interface: lt.ThingServerInterface
|
||||
|
||||
# Ensure it is an OFMThing:
|
||||
show_in_gallery: bool
|
||||
show_data_in_gallery: bool
|
||||
|
||||
gallery_data_name: str
|
||||
|
||||
gallery_data_schema: type[BaseModel]
|
||||
|
||||
# Ignore D102: No docstrings for the protocol.
|
||||
def get_gallery_data(self) -> list[BaseModel]: ... # noqa: D102
|
||||
def get_data_for_gallery(self) -> list[BaseModel]: ... # noqa: D102
|
||||
|
||||
|
||||
class GalleryThing(lt.Thing):
|
||||
|
|
@ -66,7 +66,7 @@ class GalleryThing(lt.Thing):
|
|||
gallery_providers = {
|
||||
name: thing
|
||||
for name, thing in self.all_ofm_things.items()
|
||||
if thing.show_in_gallery
|
||||
if thing.show_data_in_gallery
|
||||
}
|
||||
# cache initial list of keys as it may change in the loop
|
||||
keys = list(gallery_providers.keys())
|
||||
|
|
@ -95,5 +95,5 @@ class GalleryThing(lt.Thing):
|
|||
"""
|
||||
data_list = []
|
||||
for thing in self.gallery_providing_things.values():
|
||||
data_list += [model.model_dump() for model in thing.get_gallery_data()]
|
||||
data_list += [model.model_dump() for model in thing.get_data_for_gallery()]
|
||||
return data_list
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class SmartScanThing(OFMThing):
|
|||
"""
|
||||
|
||||
# Register with gallery.
|
||||
_show_in_gallery = True
|
||||
_show_data_in_gallery = True
|
||||
|
||||
@property
|
||||
def gallery_data_name(self) -> str:
|
||||
|
|
@ -179,7 +179,7 @@ class SmartScanThing(OFMThing):
|
|||
"""The schema (BaseModel) for passing data to the gallery."""
|
||||
return scan_directories.ScanInfo
|
||||
|
||||
def get_gallery_data(self) -> list[scan_directories.ScanInfo]:
|
||||
def get_data_for_gallery(self) -> list[scan_directories.ScanInfo]:
|
||||
"""Return all the information from the scan directories.
|
||||
|
||||
It is preferable to use the method rather than calling
|
||||
|
|
@ -622,8 +622,8 @@ class SmartScanThing(OFMThing):
|
|||
@lt.action
|
||||
def purge_empty_scans(self) -> None:
|
||||
"""Delete all scan folders containing no images at the top level."""
|
||||
# JSON is ignored as it's created before any images are captured
|
||||
for scan_info in self.get_gallery_data():
|
||||
# Use the scan list (the data read by the gallery) to check for empty scans.
|
||||
for scan_info in self.get_data_for_gallery():
|
||||
if scan_info.number_of_images == 0:
|
||||
self._delete_scan(scan_info.name)
|
||||
|
||||
|
|
@ -738,6 +738,8 @@ class SmartScanThing(OFMThing):
|
|||
"""
|
||||
if self._scan_lock.locked():
|
||||
raise RuntimeError("Can't stitch previous scans while a scan is ongoing")
|
||||
for scan in self.get_gallery_data():
|
||||
# Use the scan list (the data read by the gallery) to find any scans that
|
||||
# need stitching.
|
||||
for scan in self.get_data_for_gallery():
|
||||
if scan.dzi is None:
|
||||
self.stitch_scan(scan_name=scan.name)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class MinimalGalleryClass:
|
|||
|
||||
gallery_data_schema: type[BaseModel] = MockGalleryData
|
||||
|
||||
def get_gallery_data(self) -> list[BaseModel]:
|
||||
def get_data_for_gallery(self) -> list[BaseModel]:
|
||||
"""Return a list of Mock Gallery Data."""
|
||||
return [MockGalleryData(mock="mock", foobar="foobar")]
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class MinimalGallerySource(OFMThing, MinimalGalleryClass):
|
|||
Mixes MinimalGalleryClass into OFMThing to be recognised by the protocol.
|
||||
"""
|
||||
|
||||
show_in_gallery = True
|
||||
show_data_in_gallery = True
|
||||
|
||||
|
||||
class BadGallerySource(OFMThing):
|
||||
|
|
@ -52,11 +52,11 @@ class BadGallerySource(OFMThing):
|
|||
Shouldn't match the protocol as ``gallery_data_name`` is missing.
|
||||
"""
|
||||
|
||||
show_in_gallery = True
|
||||
show_data_in_gallery = True
|
||||
|
||||
gallery_data_schema: type[BaseModel] = MockGalleryData
|
||||
|
||||
def get_gallery_data(self) -> list[BaseModel]:
|
||||
def get_data_for_gallery(self) -> list[BaseModel]:
|
||||
"""Return a list of Mock Gallery Data."""
|
||||
return [MockGalleryData(mock="mock", foobar="foobar")]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue