vishack.data.output

Library for handling file outputs.

Functions

append_to_name(name, ext[, appendix])

Rename the name of the file if it exists

get_name_and_ext(path)

Get name and extension from a path

rename(path[, method])

Rename a file by appending something unique before extension.

rename_method_123(name, ext)

Rename the name of the file by appending bracket enclosed number.

rename_method_utc(name, ext)

Rename the name of the file by appending the current utc time.

vishack.data.output.append_to_name(name, ext, appendix='')

Rename the name of the file if it exists

Parameters
  • name (string) – The name of the file, i.e. everything before the extension

  • ext (string) – The extension of the file.

  • appendix (string) – The appendix to append onto the name

Returns

new_path – The modified path name.

Return type

string

vishack.data.output.get_name_and_ext(path)

Get name and extension from a path

Parameters

path (string) – The path of the file

Returns

  • name (string) – The name of the file, i.e. everything before the extension

  • ext (string) – The extension of the file.

vishack.data.output.rename(path, method='utc')

Rename a file by appending something unique before extension.

Parameters
  • path (string) – The path of the file to be outputted. With or without extension. If it exists, the new file will be renamed before writing so not to replace the old one.

  • method (string) – The method to rename. Available methods are ‘utc’ and ‘123’.

Returns

new_path – The modified path name.

Return type

string

vishack.data.output.rename_method_123(name, ext)

Rename the name of the file by appending bracket enclosed number.

Parameters
  • name (string) – The name of the file, i.e. everything before the extension

  • ext (string) – The extension of the file.

Returns

new_path – The modified path name.

Return type

string

vishack.data.output.rename_method_utc(name, ext)

Rename the name of the file by appending the current utc time.

Parameters
  • name (string) – The name of the file, i.e. everything before the extension

  • ext (string) – The extension of the file.

Returns

new_path – The modified path name.

Return type

string