Skip to content
Snippets Groups Projects
Commit 468b7953 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add gen_name_from_orig() to pathtools

parent e1b79f4e
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ from ij import IJ
from loci.plugins import BF
from loci.plugins.in import ImporterOptions
from ..pathtools import image_basename
from ..pathtools import gen_name_from_orig
from ..log import LOG as log
......@@ -110,6 +110,6 @@ def export_using_orig_name(imp, path, orig_name, tag, suffix, overwrite=False):
out_file : str
The full name of the exported file.
"""
out_file = os.path.join(path, image_basename(orig_name) + tag + suffix)
out_file = gen_name_from_orig(path, orig_name, tag, suffix)
export(imp, out_file, overwrite)
return out_file
......@@ -126,6 +126,30 @@ def image_basename(orig_name):
return base
def gen_name_from_orig(path, orig_name, tag, suffix):
"""Derive a file name from a given input file, an optional tag and a suffix.
Parameters
----------
path : str or object that can be cast to a str
The output path.
orig_name : str or object that can be cast to a str
The input file name, may contain arbitrary path components.
tag : str
An optional tag to be added at the end of the new file name, can be used
to denote information like "-avg" for an average projection image.
suffix : str
The new file name suffix, which also sets the file format for BF.
Returns
-------
out_file : str
The newly generated file name with its full path.
"""
name = os.path.join(path, image_basename(orig_name) + tag + suffix)
return name
# pylint: disable-msg=C0103
# we use the variable name 'exists' in its common spelling (lowercase), so
# removing this workaround will be straightforward at a later point
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment