Template

class rtcclient.template.Templater(rtc_obj, searchpath=None)[source]

A wrapped class used to generate and render templates from some copied workitems

Parameters:
  • rtc_obj – a reference to the rtcclient.client.RTCClient object
  • searchpath – the folder to store your templates. If None, the default search path (/your/site-packages/rtcclient/templates) will be loaded automatically.
getTemplate(copied_from, template_name=None, template_folder=None, keep=False, encoding='UTF-8')[source]

Get template from some to-be-copied rtcclient.workitem.Workitem

The resulting XML document is returned as a string, but if template_name (a string value) is specified, it is written there instead.

Parameters:
  • copied_from – the to-be-copied rtcclient.workitem.Workitem id (integer or equivalent string)
  • template_name – the template file name
  • template_folder – the folder to store template file
  • (default is False) (keep) –

    If True, some of below parameters (which may not be included in some customized rtcclient.workitem.Workitem type ) will remain unchangeable with the to-be-copied rtcclient.workitem.Workitem. Otherwise for False.

    • teamArea (Team Area)
    • ownedBy (Owned By)
    • plannedFor(Planned For)
    • severity(Severity)
    • priority(Priority)
    • filedAgainst(Filed Against)
  • (default is "UTF-8") (encoding) – coding format
Returns:

  • a string object: if template_name is not specified
  • write the template to file template_name: if template_name is specified

getTemplates(workitems, template_folder=None, template_names=None, keep=False, encoding='UTF-8')[source]

Get templates from a group of to-be-copied Workitems and write them to files named after the names in template_names respectively.

Parameters:
listFields(template)[source]

List all the attributes to be rendered from the template file

Parameters:template – The template to render. The template is actually a file, which is usually generated by rtcclient.template.Templater.getTemplate and can also be modified by user accordingly.
Returns:a set contains all the needed attributes
Return type:set
listFieldsFromSource(template_source)[source]

List all the attributes to be rendered directly from template source

Parameters:template_source – the template source (usually represents the template content in string format)
Returns:a set contains all the needed attributes
Return type:set
listFieldsFromWorkitem(copied_from, keep=False)[source]

List all the attributes to be rendered directly from some to-be-copied rtcclient.workitem.Workitem

Parameters:
  • copied_from – the to-be-copied rtcclient.workitem.Workitem id
  • (default is False) (keep) –

    If True, some of below parameters (which will not be included in some customized rtcclient.workitem.Workitem type ) will remain unchangeable with the to-be-copied rtcclient.workitem.Workitem. Otherwise for False.

    • teamArea (Team Area)
    • ownedBy (Owned By)
    • plannedFor(Planned For)
    • severity(Severity)
    • priority(Priority)
    • filedAgainst(Filed Against)
Returns:

a set contains all the needed attributes

Return type:

set

render(template, **kwargs)[source]

Renders the template

Parameters:
  • template – The template to render. The template is actually a file, which is usually generated by rtcclient.template.Templater.getTemplate and can also be modified by user accordingly.
  • kwargs

    The kwargs dict is used to fill the template. These two parameter are mandatory:

    • description
    • title

    Some of below parameters (which may not be included in some customized workitem type ) are mandatory if keep (parameter in rtcclient.template.Templater.getTemplate) is set to False; Optional for otherwise.

    • teamArea (Team Area)
    • ownedBy (Owned By)
    • plannedFor(Planned For)
    • severity(Severity)
    • priority(Priority)
    • filedAgainst(Filed Against)

    Actually all these needed keywords/attributes/fields can be retrieved by rtcclient.template.Templater.listFields

Returns:

the string object

Return type:

string

renderFromWorkitem(copied_from, keep=False, encoding='UTF-8', **kwargs)[source]

Render the template directly from some to-be-copied rtcclient.workitem.Workitem without saving to a file

Parameters:
  • copied_from – the to-be-copied rtcclient.workitem.Workitem id
  • (default is False) (keep) –

    If True, some of the below fields will remain unchangeable with the to-be-copied rtcclient.workitem.Workitem. Otherwise for False.

    • teamArea (Team Area)
    • ownedBy (Owned By)
    • plannedFor(Planned For)
    • severity(Severity)
    • priority(Priority)
    • filedAgainst(Filed Against)
  • (default is "UTF-8") (encoding) – coding format
  • kwargs

    The kwargs dict is used to fill the template. These two parameter are mandatory:

    • description
    • title

    Some of below parameters (which may not be included in some customized workitem type ) are mandatory if keep is set to False; Optional for otherwise.

    • teamArea (Team Area)
    • ownedBy (Owned By)
    • plannedFor(Planned For)
    • severity(Severity)
    • priority(Priority)
    • filedAgainst(Filed Against)

    Actually all these needed keywords/attributes/fields can be retrieved by rtcclient.template.Templater.listFieldsFromWorkitem

Returns:

the string object

Return type:

string