carputils
Doxygen code documentation for the python framework controlling openCARP
Functions | Variables
carputils.clean Namespace Reference

Functions

def clean_directory (filelist=None, globstr=None, regex=None)
 Remove the specified files. More...
 
def overwrite_mode_prompt (name, directory)
 
def overwrite_mode_error (name, directory)
 
def overwrite_check (name, mode='prompt')
 Make sure the user does not overwrite an existing output directory. More...
 

Variables

bool OVERWRITE_CHECK = True
 
bool CLEAN_BATCH = False
 
int CLEAN_REMOVED_COUNT = 0
 
dictionary OVERWRITE_MODES
 

Function Documentation

◆ clean_directory()

def carputils.clean.clean_directory (   filelist = None,
  globstr = None,
  regex = None 
)

Remove the specified files.

This convenience method is provided to minimise duplication of directory cleanup code in run scripts. Files and directories can be specified by an explicit list, glob expression or regular expression. The user is prompted with a list of files to be removed before anything is done. Exits the program when done.

Parameters
filelistlist of str List of file and directory names to be removed.
globstrstr Glob expression (e.g. 'output_*' to match files and directories for removal).
regexstr Regular expression (e.g. '^output_\\d{4}') to match files and directories for removal.

◆ overwrite_check()

def carputils.clean.overwrite_check (   name,
  mode = 'prompt' 
)

Make sure the user does not overwrite an existing output directory.

Parameters
simIDstr The simulation output directory.
modestr, optional The overwrite mode - one of 'append','prompt', 'error', 'delete' or 'overwrite'

◆ overwrite_mode_error()

def carputils.clean.overwrite_mode_error (   name,
  directory 
)

◆ overwrite_mode_prompt()

def carputils.clean.overwrite_mode_prompt (   name,
  directory 
)

Variable Documentation

◆ CLEAN_BATCH

bool carputils.clean.CLEAN_BATCH = False

◆ CLEAN_REMOVED_COUNT

int carputils.clean.CLEAN_REMOVED_COUNT = 0

◆ OVERWRITE_CHECK

bool carputils.clean.OVERWRITE_CHECK = True

◆ OVERWRITE_MODES

dictionary carputils.clean.OVERWRITE_MODES
Initial value:
1 = {'prompt': overwrite_mode_prompt,
2  'error': overwrite_mode_error,
3  'delete': lambda n, d: True,
4  'overwrite': lambda n, d: False,
5  'append': lambda n, d: False}