Improve scan naming logic and type hints
Removed an unnecessary `Optional` and removed the `scan_` prefix from scans that have a non-empty name. I also added a closing ` to a logging statement.
This commit is contained in:
parent
e483c3ddfb
commit
dca2d1fabb
1 changed files with 16 additions and 4 deletions
|
|
@ -341,12 +341,24 @@ class SmartScanThing(Thing):
|
|||
scan_name = self.latest_scan_name
|
||||
return os.path.join(self.scans_folder_path, scan_name)
|
||||
|
||||
def new_scan_folder(self, scan_name: Optional[str]="") -> str:
|
||||
"""Create a new empty folder, into which we can save scan images"""
|
||||
def new_scan_folder(self, scan_name: str="scan") -> str:
|
||||
"""Create a new empty folder, into which we can save scan images
|
||||
|
||||
The folder will be named `{scan_name}_000001/` where the number is
|
||||
zero-padded to be 6 digits long (to allow correct sorting if the
|
||||
scans are ordered alphanumerically).
|
||||
|
||||
Note that if you have discontinuous numbering (e.g. you've got scans
|
||||
numbered 1 through 10, but you deleted scan 5), then the gaps will
|
||||
get filled in - so there's no guarantee, for now, that the numbers
|
||||
will correspond to order of creation. This may change in the future.
|
||||
"""
|
||||
if not os.path.exists(self.scans_folder_path):
|
||||
os.makedirs(self.scans_folder_path)
|
||||
if not scan_name:
|
||||
scan_name = "scan"
|
||||
for j in range(999999):
|
||||
folder_path = os.path.join(self.scans_folder_path, f"scan_{scan_name}{j:06}")
|
||||
folder_path = os.path.join(self.scans_folder_path, f"{scan_name}_{j:06}")
|
||||
if not os.path.exists(folder_path):
|
||||
os.makedirs(folder_path)
|
||||
self._latest_scan_name = os.path.basename(folder_path)
|
||||
|
|
@ -364,7 +376,7 @@ class SmartScanThing(Thing):
|
|||
csm: CSMDep,
|
||||
background_detect: BackgroundDep,
|
||||
recentre: RecentreStage,
|
||||
scan_name: Optional[str]
|
||||
scan_name: str="",
|
||||
):
|
||||
"""Move the stage to cover an area, taking images that can be tiled together.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue