def output_filename(source_filename, destination_dir, mode, suffix):
# type: (str, str, str, str) -> str
"""Duplicates the source filename in the destination directory, adding or stripping
a suffix as needed.
:param str source_filename: Full file path to source file
:param str destination_dir: Full file path to destination directory
:param str mode: Operating mode (encrypt/decrypt)
:param str suffix: Suffix to append to output filename
:returns: Full file path of new destination file in destination directory
:rtype: str
"""
if suffix is None:
suffix = OUTPUT_SUFFIX[mode]
else:
_LOGGER.debug('Using custom suffix "%s" to create output file', suffix)
filename = source_filename.rsplit(os.sep, 1)[-1]
_LOGGER.debug('Duplicating filename %s into %s', filename, destination_dir)
return os.path.join(destination_dir, filename) + suffix
评论列表
文章目录