curPattern - noetl/noetl GitHub Wiki

E.g. cursorReplaced = curPattern("echo 'On cursor date [%Y%m]'", "201501", "date", "%Y%m")

Parameters

  • valIn: String to replace cursor patterns in
  • cur: default = None; cursor to insert into valIn
  • curType: default = date; cursor type - date or integer
  • dateFormat: default = %Y%m; dateFormat (only used if cursor is a date)

Key Variables

  • varPattern : [ ]
  • varList: List of all the sections in valIn that match varPattern
  • varlistId: Index of the element during the iteration through varList
  • replaceCur: date of the cursor (if cursor is a date) formatted by the dateFormat
  • replaceFormat: used to replace the element in varList matching varPattern
  • val: valIn string with all cursor patterns replaced

Functionality

  • CurPattern finds all instances of varPattern, stores them in varList, and iterates through the indices of varList.
  • If the curType is date, the varPattern in val is replaced with the cursor formatted by dateFormat.
  • Otherwise, if curType is integer, the varPattern in val is simply replaced with the cursor.
  • CurPattern returns val.

Except Statement

If an error arises, the except block writes to the log file, recording the time, current step, next step, step description, the exit code, and the error message. The exitCode is set equal to -1, indicating a failure.

Return Value

Returns val (all varPatterns replaced with the cursor).