Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The package contains objects representing syntactical blocks of a TM1 rule. All contained classes are derived from a common ancestor TM1RuleToken. The root class contains essential method providing the splicing conversion. Derived classes redefine this method to achieve desired splicing conversion. Contained objects are described in following paragraphs.

TM1RuleToken (class in TM1RuleToken.py)

The class represents any string (token) contained within the associated rule with starting and ending position enumerated as number of characters from the rule beginning. This reflects notation in which parser enumerates parsed tokens when calling custom actions in Parser/TM1RuleParser.

The class defines convert method that is by default returning original text as returned from Parser/TM1RuleParser during the rule parsing (token passthrough). However this method is overloaded in classes descending from this base class to achieve correct splicing.

The class defines following attributes:

Attribute

Type

Usage

text

str

Text as parsed by Parser/TM1RuleParser when calling custom actions that cover all cases except for TM1 calculation rule and feeder commands.

start

int

Global position of the text start (inclusive) within the TM1 rule, calculated as zero based number of characters from start of the rule.

end

int

Global position of the text end (inclusive) within the TM1 rule, calculated as zero based number of characters from start of the rule.

The class exposes following methods:

Method

Usage

update

Method updates intrinsic attributes of the object by text, eventually start and end attributes if provided.

len

Method returns length of text attribute as number of contained characters.

get_text

Method returns original value of text attribute.

convert

Method returns original value of text attribute.

TM1CalcRule (class in TM1CalcRule.py, derived from TM1RuleToken)

This class represents entire TM1 calculation rule or a feeder command. It breaks down the calculation rule or a feeder into two essential parts - area statement (part before equal sign) and statement (part following equal sign, sign inclusive).

The class redefines convert method by returning string obtained by concatenating result of convert method of associated area statement and statement. Each object of this class is aware of which regions the associated rule is encapsulated in and it has link to a directive resolver used to return all directives applying to the associated rule. This is essential information to be able to properly splice the associated rule by applying conversion based on region membership and associated directives.

The class defines following attributes:

Attribute

Type

Usage

area_statement

TM1RuleAreaStatement

Link to associated area statement of the TM1 rule or the feeder statement.

statement

TM1RuleToken

Link to token following the area statement including equal sign.

directives_resolver

TM1DirectiveResolver

Link to directive resolver to identify all splicing directives that apply to the TM1 rule.

scopes

List[str]

List of region names in which the TM1 rule or feeder statement is encapsulated.

The class exposes following methods:

Method

Usage

convert

Method returns concatenated string composed from result of convert method of associated area_statement and statement.

TM1RuleAreaStatement (class in TM1RuleAreaStatement.py, derived from TM1RuleToken)

The class represents area statement of TM1 calculation rule or a feeder command. The area statement is decomposed to dimensions and hierarchy:element pairs belonging to each of the dimensions. This implies that the rule has to contain full specification of each element in the area statement. Not following this pattern in TM1 development will result in an error during splicing of the rule.

The convert method implements splicing of dimensional elements based on directives that apply to the associated TM1CalcRule. Once the directives are applied, the convert method will return modified area statement based on apply method output.

The class defines following attributes:

Attribute

Type

Usage

pre_format

TM1RuleAreaStatement

Link to associated area statement of the TM1 rule or the feeder statement.

post_format

directives_resolver

TM1DirectiveResolver

Link to directive resolver to identify all splicing directives that apply to the area statement of the TM1 rule.

orig_dim_elem_dict

converted_dim_elem_dict

applied_directives

calc_rule

The class exposes following methods:

Method

Usage

set_calc_rule

Method returns concatenated string composed from result of convert method of associated area_statement and statement.

get_dimensions

get_elements

add_converted_dimension

apply_directives

convert

  • No labels