slmsuite.misc.files.generate_path

generate_path(path, name, extension=None, kind='file', digit_count=5, path_count=1)[source]

Generate a file path like path/name_id.extension or a directory path like path/name_id where id is a unique numeric identifier.

Parameters
  • path (str) – Top level directory to create the object in. If path does not exist, it and nonexistent parent directories will be created.

  • name (str) – Identifier for the object. This should not contain underscores.

  • extension (str or None) – The extension to append to the file name, not including the . separator. If None, no extension will be added.

  • kind ({"file", "dir"}) – String that identifies what type of object to create. If kind="dir" the directory will be created.

  • digit_count (int) – The number of digits to use in the numeric identifier.

  • path_count (int) – The number of paths to create. Currently only applicable to file creation.

Returns

file_path – The full path or paths requested.

Return type

str or list of str

Notes

This function is not thread safe.