class UniqueFilenameMaker(object): (source)
Constructor: UniqueFilenameMaker(output_dir, rel_dir, alt_dir, chunk_size, ...)
A class that generates unique output paths in a directory.
This class provides a get_output_path
method that generates unique
filenames in the specified output directory.
If an input path is provided, its filename is maintained, unless a name conflict in output_dir would occur, in which case an index of the form "-%d" % count is appended to the filename.
If no input filename is provided, an output filename of the form <output_dir>/<count><default_ext> is generated, where count is the number of files in output_dir.
If no output_dir is provided, then unique filenames with no base directory are generated.
If a rel_dir is provided, then this path will be stripped from each input path to generate the identifier of each file (rather than just its basename). This argument allows for populating nested subdirectories in output_dir that match the shape of the input paths.
If alt_dir is provided, you can use get_alt_path
to retrieve
the equivalent path rooted in this directory rather than output_dir.
Parameters | |
output | a directory in which to generate output paths |
rel | an optional relative directory to strip from each path.
The path is converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
alt | an optional alternate directory in which to generate
paths when get_alt_path is called |
chunk | if provided, output paths will be nested in subdirectories of output_dir with at most this many files per subdirectory. Has no effect if a rel_dir is provided |
default | the file extension to use when generating default output paths |
ignore | whether to omit file extensions when checking for duplicate filenames |
ignore | whether to ignore existing files in output_dir for output filename generation purposes |
idempotent | whether to return the same output path when the same input path is provided multiple times (True) or to generate new output paths (False) |
Method | __init__ |
Undocumented |
Method | get |
Returns the alternate path for the given output path generated by get_output_path . |
Method | get |
Returns a unique output path. |
Method | seen |
Checks whether we've already seen the given input path. |
Instance Variable | alt |
Undocumented |
Instance Variable | chunk |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | idempotent |
Undocumented |
Instance Variable | ignore |
Undocumented |
Instance Variable | ignore |
Undocumented |
Instance Variable | output |
Undocumented |
Instance Variable | rel |
Undocumented |
Method | _setup |
Undocumented |
Instance Variable | _chunk |
Undocumented |
Instance Variable | _chunk |
Undocumented |
Instance Variable | _chunk |
Undocumented |
Instance Variable | _default |
Undocumented |
Instance Variable | _filename |
Undocumented |
Instance Variable | _filepath |
Undocumented |
Instance Variable | _idx |
Undocumented |
Undocumented
Returns the alternate path for the given output path generated by
get_output_path
.
Parameters | |
output | an output path |
altNone | a directory in which to return the alternate path.
If not provided, alt_dir is used |
Returns | |
the corresponding alternate path |