From 1a47a68a628f2e64dc7d030ee6d382779e9612a9 Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 25 Aug 2023 13:17:35 +0100 Subject: [PATCH 1/3] Move 'converted' into SUFFIX constant --- src/omero_mkngff/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index 654f416..b08963d 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -27,6 +27,7 @@ from omero.cli import BaseControl, Parser from omero.sys import ParametersI +SUFFIX = "converted" HELP = """Plugin to swap OMERO filesets with NGFF CLI plugin used to swap an existing OMERO fileset with @@ -197,7 +198,7 @@ def sql(self, args: Namespace) -> None: self.ctx.die(401, f"Symlink target does not exist: {args.symlink_target}") return - # create *_converted/path/to/zarr directory containing symlink to data + # create *_SUFFIX/path/to/zarr directory containing symlink to data if args.symlink_repo: prefix_dir = os.path.join(args.symlink_repo, prefix) self.ctx.err(f"Checking for prefix_dir {prefix_dir}") @@ -206,7 +207,7 @@ def sql(self, args: Namespace) -> None: symlink_container = f"{symlink_path.parent}" if symlink_container.startswith("/"): symlink_container = symlink_container[1:] # remove "/" from start - symlink_dir = os.path.join(f"{prefix_dir}_converted", symlink_container) + symlink_dir = os.path.join(f"{prefix_dir}_{SUFFIX}", symlink_container) self.ctx.err(f"Creating dir at {symlink_dir}") os.makedirs(symlink_dir, exist_ok=True) @@ -223,7 +224,7 @@ def sql(self, args: Namespace) -> None: row_path = str(row_path)[1:] # remove "/" from start rows.append( ROW.format( - PATH=f"{prefix_path}/{prefix_name}_converted/{row_path}/", + PATH=f"{prefix_path}/{prefix_name}_{SUFFIX}/{row_path}/", NAME=row_name, MIME=row_mime, ) @@ -232,7 +233,7 @@ def sql(self, args: Namespace) -> None: self.ctx.out( TEMPLATE.format( OLD_FILESET=args.fileset_id, - PREFIX=f"{prefix_path}/{prefix_name}_converted/", + PREFIX=f"{prefix_path}/{prefix_name}_{SUFFIX}/", ROWS=",\n".join(rows), REPO=self.get_uuid(args), UUID=args.secret, From c9cb76b24f982be9f9a5d39e195ebee6df7f47de Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 25 Aug 2023 16:31:24 +0100 Subject: [PATCH 2/3] Shortern paths and symlink dirs --- src/omero_mkngff/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index b08963d..e28eed3 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -207,7 +207,7 @@ def sql(self, args: Namespace) -> None: symlink_container = f"{symlink_path.parent}" if symlink_container.startswith("/"): symlink_container = symlink_container[1:] # remove "/" from start - symlink_dir = os.path.join(f"{prefix_dir}_{SUFFIX}", symlink_container) + symlink_dir = f"{prefix_dir}_{SUFFIX}" self.ctx.err(f"Creating dir at {symlink_dir}") os.makedirs(symlink_dir, exist_ok=True) @@ -220,6 +220,8 @@ def sql(self, args: Namespace) -> None: rows = [] for row_path, row_name, row_mime in self.walk(symlink_path): + # remove common path to shorten + row_path = str(row_path).replace(f"{symlink_path.parent}", "") if str(row_path).startswith("/"): row_path = str(row_path)[1:] # remove "/" from start rows.append( From 9f9d1aa83c995811d4cdec0f8e79ccc8fcadee6f Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 25 Aug 2023 16:32:24 +0100 Subject: [PATCH 3/3] Use 'mkngff' instead of 'converted' for path suffix --- src/omero_mkngff/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index e28eed3..da725ea 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -27,7 +27,7 @@ from omero.cli import BaseControl, Parser from omero.sys import ParametersI -SUFFIX = "converted" +SUFFIX = "mkngff" HELP = """Plugin to swap OMERO filesets with NGFF CLI plugin used to swap an existing OMERO fileset with