module: utils¶
common routines for many modules
support | description |
---|---|
chdir() |
change current IOC shell directory |
datenow() |
current date/time, as a str |
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_c_comments() |
strip out a C-style comment |
LOG_FILE |
default log file name (must be defined before logging is started) |
LOGGING_DETAIL |
maximum level of detail to report in log (default=2, range: 0-5) |
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.
detailedExceptionLog
(title='', print_traceback=True)[source]¶ enter details of an exception to the log (developer tool)
- always log that an exception was reported
- the full traceback details are logged at a higher level
-
iocdoc.utils.
logMessage
(text, detail=2)[source]¶ log a message
Parameters: - text (obj) – item to be logged, assumed to be a string but will be rendered with
str(text)
- detail (int) – interest level for this logging item, must be <= LOGGING_DETAIL to be logged
- text (obj) – item to be logged, assumed to be a string but will be rendered with
-
iocdoc.utils.
remove_c_comments
(text)[source]¶ strip out a C-style comment
/* such as this */
Parameters: text (str) – text with possible comment See: http://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments
-
iocdoc.utils.
setLogDetailLevel
(detail=2)[source]¶ define the logging (reporting) detail level
Parameters: detail (int) – interest level for logging items, must be <= LOGGING_DETAIL to be logged
-
iocdoc.utils.
setLogFile
(logFile)[source]¶ define the log file name
Parameters: logFile (str) – name of log file to be used Raises: RuntimeError – if called after logging has started
-
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