get_folder

lib.utils.get_folder(path: str, make_folder: bool = True) str

Return a path to a folder, creating it if it doesn’t exist

Parameters:
  • path (str) – The path to the folder to obtain

  • make_folder (bool) – True if the folder should be created if it does not already exist, False if the folder should not be created

Returns:

  • The path to the requested folder. If make_folder is set to False and the requested path

  • does not exist, then None is returned

Return type:

str

Example

>>> from lib.utils import get_folder
>>> get_folder('/tmp/my_folder')
'/tmp/my_folder'
>>> get_folder('/tmp/my_folder', make_folder=False)
''