From 833938e77d63b1e598783e45ad120146316a6f03 Mon Sep 17 00:00:00 2001 From: Luca Lianas Date: Fri, 19 May 2023 11:32:01 +0200 Subject: [PATCH] refactor: extended support for rescanned slides --- .../management/commands/import_ome_slides.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/promort/slides_manager/management/commands/import_ome_slides.py b/promort/slides_manager/management/commands/import_ome_slides.py index 1afef02..f7918e7 100644 --- a/promort/slides_manager/management/commands/import_ome_slides.py +++ b/promort/slides_manager/management/commands/import_ome_slides.py @@ -34,14 +34,17 @@ class Command(BaseCommand): Import slides from a running OMERO server (with ome_seadragon plugin) to ProMort and create related Case and Slide objects """ + + def _get_slide_name_re(self): + return r'^(?P[\w]+)[_-](?P[\w]+)(?:[ \(\)\w]+){0,1}.(?P[a-w]+) +\[0\]$' def _is_valid_slide_label(self, slide_label): - regex = re.compile(r'^(?P[\w]+)[_-](?P[\w]{1,2})(?:[ \(\)\w]+){0,1}.(?P[a-w]+) +\[0\]$') + regex = re.compile(self._get_slide_name_re()) res = regex.match(slide_label) return res is not None def _split_slide_name(self, slide_name): - regex = re.compile(r'^(?P[\w]+)[_-](?P[\w]{1,2})(?:[ \(\)\w]+){0,1}.(?P[a-w]+) +\[0\]$') + regex = re.compile(self._get_slide_name_re()) res = regex.match(slide_name) if res: return res.group("case_id", "slide_index")