corelp.folder module

corelp.folder(path, /, warning=True, *, new=True)[source]

This function creates a new folder, while crushing previous instances if already exists.

Parameters:
  • path (str or Path) – Full path to folder to create.

  • warning (bool) – True to print a warning if a folder already exist.

  • new (bool) – True to crush folder if already exists.

Returns:

folder_path – Path object to created folder.

Return type:

Path

Raises:

SyntaxError – If user answers no to crush existing folder when warning asked.

Examples

>>> from corelp import folder
...
>>> folder_path = folder(path) # Creates folder
>>> folder_path = folder(path) # Launch warning before crushing
>>> folder_path = folder(path, warning=False) # Crushes without warning
>>> folder_path = folder(path, new=False) # Does not crush old folder