yaml_tools.templates module

Template bits for generating SSG-style controls in YAML.

yaml_tools.templates.generate_control(context)[source]

Render an ID template string given a context dict with key names for Control ID template fields, eg:

'caps': 'AC-12(2)',
'name': 'Control (or Control Enhancement) Name',
'notes': 'Discussion',
'description': 'Control Text',
'status': 'pending',
Parameters:

context (Dict) – dict providing keys,values for ID_TEMPLATE fields

Returns:

yaml control ID string

Return type:

str

yaml_tools.templates.xform_id(string, strip_trailing_zeros=False)[source]

Transform control ID strings, add leading zeros in forward direction:

AC-12(2) <==> ac-12.02

Caller should filter zero-length input or handle IndexError as needed.

Parameters:
  • string (str) – id string in one of the above formats

  • strip_trailing_zeros (bool) – off by default

Returns:

opposite ID format string

Return type:

str