Skip to content

Commit a1fea8d

Browse files
committed
Updated code to remove walrus equalities that are used unintuitively
1 parent b27e198 commit a1fea8d

1 file changed

Lines changed: 40 additions & 48 deletions

File tree

  • src/murfey/client/contexts

src/murfey/client/contexts/fib.py

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -290,49 +290,43 @@ def post_transfer(
290290
logger.info(f"Updating metadata for site {site_num}")
291291

292292
# Post drift correction GIF request if it hasn't already been done
293-
if (
294-
fib_image := self._drift_correction_images.get(site_num, None)
295-
) is not None and not fib_image.is_submitted:
293+
fib_image = self._drift_correction_images.get(site_num, None)
294+
if fib_image is not None and not fib_image.is_submitted:
296295
# Construct the output file name if it doesn't already exist
297296
if (output_file := fib_image.output_file) is None:
298-
if not (
299-
source := _get_source(transferred_file, environment)
300-
):
297+
source = _get_source(transferred_file, environment)
298+
if source is None:
301299
logger.warning(
302300
f"No source found for file {transferred_file}"
303301
)
304302
continue
305-
if not (
306-
destination_file := _file_transferred_to(
307-
environment=environment,
308-
source=source,
309-
file_path=transferred_file,
310-
rsync_basepath=Path(
311-
self._machine_config.get("rsync_basepath", "")
312-
),
313-
)
314-
):
303+
destination_file = _file_transferred_to(
304+
environment=environment,
305+
source=source,
306+
file_path=transferred_file,
307+
rsync_basepath=Path(
308+
self._machine_config.get("rsync_basepath", "")
309+
),
310+
)
311+
if destination_file is None:
315312
logger.warning(
316313
f"Could not find destination file path for {transferred_file.name!r}"
317314
)
318315
continue
319-
if (
320-
output_dir := self._determine_output_dir(
321-
site_num,
322-
destination_file,
323-
environment,
324-
)
325-
) is None:
316+
output_dir = self._determine_output_dir(
317+
site_num, destination_file, environment
318+
)
319+
if output_dir is None:
326320
logger.warning(
327321
f"Could not determine output directory for lamella {site_num}"
328322
)
329323
continue
324+
output_file = (
325+
output_dir
326+
/ "drift_correction"
327+
/ f"lamella_{site_num}.gif"
328+
)
330329
with lock:
331-
output_file = (
332-
output_dir
333-
/ "drift_correction"
334-
/ f"lamella_{site_num}.gif"
335-
)
336330
self._drift_correction_images[
337331
site_num
338332
].output_file = output_file
@@ -366,19 +360,17 @@ def post_transfer(
366360
"Electron Snapshot" in transferred_file.name
367361
and transferred_file.suffix in (".tif", ".tiff")
368362
):
369-
if not (source := _get_source(transferred_file, environment)):
363+
source = _get_source(transferred_file, environment)
364+
if source is None:
370365
logger.warning(f"No source found for file {transferred_file}")
371366
return None
372-
if not (
373-
destination_file := _file_transferred_to(
374-
environment=environment,
375-
source=source,
376-
file_path=transferred_file,
377-
rsync_basepath=Path(
378-
self._machine_config.get("rsync_basepath", "")
379-
),
380-
)
381-
):
367+
destination_file = _file_transferred_to(
368+
environment=environment,
369+
source=source,
370+
file_path=transferred_file,
371+
rsync_basepath=Path(self._machine_config.get("rsync_basepath", "")),
372+
)
373+
if destination_file is None:
382374
logger.warning(
383375
f"Could not find destination file path for {transferred_file.name!r}"
384376
)
@@ -569,17 +561,17 @@ def _make_drift_correction_gif(
569561
f"Could not extract metadata from file {file}", exc_info=True
570562
)
571563
return None
572-
if not (source := _get_source(file, environment)):
564+
source = _get_source(file, environment)
565+
if source is None:
573566
logger.warning(f"No source found for file {file}")
574567
return
575-
if not (
576-
destination_file := _file_transferred_to(
577-
environment=environment,
578-
source=source,
579-
file_path=file,
580-
rsync_basepath=Path(self._machine_config.get("rsync_basepath", "")),
581-
)
582-
):
568+
destination_file = _file_transferred_to(
569+
environment=environment,
570+
source=source,
571+
file_path=file,
572+
rsync_basepath=Path(self._machine_config.get("rsync_basepath", "")),
573+
)
574+
if destination_file is None:
583575
logger.warning(f"Could not find destination file path for {file.name!r}")
584576
return
585577

0 commit comments

Comments
 (0)