module: utils

common routines for many modules

support description
chdir() change current IOC shell directory
datenow() get a file either from the cache or from storage
detailedExceptionLog() log the details of an exception
FileRef associate filename and line number of an object
logMessage() log a message
strip_outer_pair() remove outer symbols from text
strip_outer_quotes() strip outer quotes (either single or double) from text
remove_comments() strip out a C-style comment
LOG_FILE default log file name
strip_parentheses() remove outer parentheses from text
strip_quotes() strip outer double quotes from text
class iocdoc.utils.FileRef(filename, linenumber, colnumber, obj)[source]

Bases: object

associate filename and line number of an object

iocdoc.utils.chdir(newDir, nfsMounts={})[source]

change the current working directory for the IOC shell

Parameters:newDir – name of new directory
Returns:success (True) or failure (False)
iocdoc.utils.datenow()[source]

return date and time now as a string

iocdoc.utils.detailedExceptionLog(title='', print_traceback=True)[source]

enter details of an exception to the log (developer tool)

iocdoc.utils.logMessage(text)[source]

log a message

iocdoc.utils.remove_comments(text)[source]

strip out a C-style comment

/* such as this */
See:http://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments
iocdoc.utils.strip_outer_pair(text, left, right=None)[source]

remove outer symbols from text

Parameters:
  • text – string
  • left – symbol on left side
  • right – symbol on right side (default is left-side symbol)
Returns:

modified string

Raises:

Exception – left and right must have len(..) == 1

iocdoc.utils.strip_outer_quotes(text)[source]

strip outer quotes (either single or double) from text

Returns:text without comments
iocdoc.utils.strip_parentheses(text)[source]

remove outer parentheses from text

Parameters:text – string
Returns:modified string
iocdoc.utils.strip_quotes(text, quote='"')[source]

strip outer double quotes from text

Returns:text without comments