file

Functions to deal, in general, with files

Suffixing the name of a file

A small utility function to derive a file path by appending something to the name (and only to the name).


source

supplement_file_name

 supplement_file_name (file:str|pathlib.Path, sup:str)

Adds a string between the file name in a path and the suffix

Type Details
file str | pathlib.Path File name
sup str String to be added
Returns Path “Supplemented” file name
supplement_file_name('/a/b/picture.tex', '1')
PosixPath('/a/b/picture_1.tex')

Generating a unique file name


source

unique_name

 unique_name (file:str|pathlib.Path)

Builds a unique file name out of a given one

Type Details
file str | pathlib.Path Input file name
Returns Path Unique file name
unique_name('docs/a.pdf')
PosixPath('docs/a_77208efe-c6fc-11ed-afc3-d8cb8aeac823.pdf')