buildingmotif.template_compilation#

Module Attributes

RULES

Notes: - maybe more useful for authoring than for distribution - "compile" into template definitions that then get distributed - standardize the "subject" of the template: 'name' param - have rules generate dependencies rather than introducing additional subjects? - give the rules/macros access to the library and/or the template they are associated with?: - new signature: def foo(library, template, *args, **kwargs) -> rdflib.Graph - don't hardcode template names into these rules/macros --- pass in from user

Functions

bacnet(*args, **kwargs)

Adds template fields for each of the param names in args to ensure they have BACnet references.

body(*args, **kwargs)

Returns the first value of the body argument as the template body.

compile_template_spec(spec)

Compiles a template specification into the body of a template by applying rules defined in this file and others.

feeds(*args, **kwargs)

_summary_

hasType(*args, **kwargs)

_summary_

isFedBy(*args, **kwargs)

_summary_

parts(*args, **kwargs)

_summary_

points(*args, **kwargs)

_summary_

rule(name)

This decorator is applied to a function in order to register that function as a rule that can be executed during template compilation.

RULES: Dict[str, Callable] = {'bacnet': <function bacnet>, 'body': <function body>, 'downstream': <function feeds>, 'hasPart': <function parts>, 'hasPoint': <function points>, 'type': <function hasType>, 'upstream': <function isFedBy>}#

Notes: - maybe more useful for authoring than for distribution - “compile” into template definitions that then get distributed - standardize the “subject” of the template: ‘name’ param - have rules generate dependencies rather than introducing additional subjects? - give the rules/macros access to the library and/or the template they are associated with?:

  • new signature: def foo(library, template, *args, **kwargs) -> rdflib.Graph

  • don’t hardcode template names into these rules/macros — pass in from user

rule(name: str)[source]#

This decorator is applied to a function in order to register that function as a rule that can be executed during template compilation.

Parameters:

name (str) – name

body(*args, **kwargs) Graph[source]#

Returns the first value of the body argument as the template body.

Returns:

graph of first value of body argument

Return type:

rdflib.Graph

hasType(*args, **kwargs) Graph[source]#

_summary_

Returns:

_description_

Return type:

rdflib.Graph

points(*args, **kwargs) Graph[source]#

_summary_

Returns:

_description_

Return type:

rdflib.Graph

parts(*args, **kwargs) Graph[source]#

_summary_

Returns:

_description_

Return type:

rdflib.Graph

isFedBy(*args, **kwargs) Graph[source]#

_summary_

Returns:

_description_

Return type:

rdflib.Graph

feeds(*args, **kwargs) Graph[source]#

_summary_

Returns:

_description_

Return type:

rdflib.Graph

bacnet(*args, **kwargs) Graph[source]#

Adds template fields for each of the param names in args to ensure they have BACnet references.

Returns:

a graph with BACnet references added

Return type:

rdflib.Graph

compile_template_spec(spec: Dict) Dict[source]#

Compiles a template specification into the body of a template by applying rules defined in this file and others.

Parameters:

spec (Dict) – the Python dictionary that is the result of decoding the YAML structure (usually a dictionary or list) defining the template

Raises:

ValueError – if unknown rule

Returns:

the template spec containing the compiled body

Return type:

Dict