# cwl_utils.expression

CWL Expression parsing.

## Attributes

`OLD_ESCAPE_CWL_VERSIONS` |

## Classes

`t` | Tokens.

## Functions

`scanner`(scan) | Find JS relevant punctuation in a string.
`evaluator`(js_engine, ex, obj, jslib, fullJS, **kwargs) |
`interpolate`(scan, rootvars[, jslib, fullJS, ...]) | Interpolate and evaluate.
`jshead`(engine_config, rootvars) | Make sure all the byte strings are converted to str in rootvars dict.
`needs_parsing`(snippet) |
`do_eval`(ex, jobinput, requirements, outdir, tmpdir, ...) | Evaluate the given CWL expression, in context.

## Module Contents

cwl_utils.expression.OLD_ESCAPE_CWL_VERSIONS: Final[collections.abc.Container[str]] = ('v1.0', 'v1.1.0-dev1', 'v1.1', 'v1.2.0-dev1', 'v1.2.0-dev2', 'v1.2.0-dev3')

class cwl_utils.expression.t

  Bases: `enum.Enum`

  digraph inheritance9319f84657 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Enum" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Create a collection of name/value pairs."]; "t" [URL="#cwl_utils.expression.t",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Tokens."]; "Enum" -> "t" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

  Tokens.

  DEFAULT = 0
  DOLLAR = 1
  PAREN = 2
  BRACE = 3
  SINGLE_QUOTE = 4
  DOUBLE_QUOTE = 5
  BACKSLASH = 6

cwl_utils.expression.scanner(scan)

  Find JS relevant punctuation in a string.

  Parameters:

    scan (str)

  Return type:

    tuple[int, int] | None

cwl_utils.expression.evaluator(js_engine, ex, obj, jslib, fullJS, **kwargs)
  Parameters:

    - js_engine (cwl_utils.sandboxjs.JSEngine)

    - ex (str)

    - obj (cwl_utils.types.CWLParameterContext)

    - jslib (str)

    - fullJS (bool)

    - kwargs (Any)

  Return type:

    cwl_utils.types.CWLOutputType | None

cwl_utils.expression.interpolate(scan, rootvars, jslib='', fullJS=False, strip_whitespace=True, escaping_behavior=2, convert_to_expression=False, js_engine=None, **kwargs)

  Interpolate and evaluate.

  Note: only call with convert_to_expression=True on CWL Expressions in $() form that need interpolation.

  Parameters:

    - scan (str)

    - rootvars (cwl_utils.types.CWLParameterContext)

    - jslib (str)

    - fullJS (bool)

    - strip_whitespace (bool)

    - escaping_behavior (int)

    - convert_to_expression (bool)

    - js_engine (cwl_utils.sandboxjs.JSEngine | None)

    - kwargs (Any)

  Return type:

    cwl_utils.types.CWLOutputType | None

cwl_utils.expression.jshead(engine_config, rootvars)

  Make sure all the byte strings are converted to str in rootvars dict.

  Parameters:

    - engine_config (list[str])

    - rootvars (cwl_utils.types.CWLParameterContext)

  Return type:

    str

cwl_utils.expression.needs_parsing(snippet)
  Parameters:

    snippet (Any)

  Return type:

    bool

cwl_utils.expression.do_eval(ex, jobinput, requirements, outdir, tmpdir, resources, context=None, timeout=default_timeout, strip_whitespace=True, cwlVersion='', **kwargs)

  Evaluate the given CWL expression, in context.

  Parameters:

    - timeout (float) – The maximum number of seconds to wait while executing.

    - ex (cwl_utils.types.CWLOutputType | None)

    - jobinput (cwl_utils.types.CWLObjectType)

    - requirements (list[cwl_utils.types.CWLObjectType])

    - outdir (str | None)

    - tmpdir (str | None)

    - resources (dict[str, float | int])

    - context (cwl_utils.types.CWLOutputType | None)

    - strip_whitespace (bool)

    - cwlVersion (str)

    - kwargs (Any)

  Return type:

    cwl_utils.types.CWLOutputType | None