parser_depth_average_rule
Module for ParserDepthAverageRule class
!!! classes ParserDepthAverageRule
ParserDepthAverageRule (IParserRuleBase)
Class for creating a ParserDepthAverageRule
Source code in parsers/parser_depth_average_rule.py
class ParserDepthAverageRule(IParserRuleBase):
"""Class for creating a ParserDepthAverageRule"""
@property
def rule_type_name(self) -> str:
"""Type name for the rule"""
return "depth_average_rule"
def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData:
"""Parses the provided dictionary to a IRuleData
Args:
dictionary (Dict[str, Any]): Dictionary holding the values
for making the rule
Returns:
RuleBase: Rule based on the provided data
"""
name: str = get_dict_element("name", dictionary)
bed_level_variable = get_dict_element("bed_level_variable", dictionary)
water_level_variable = get_dict_element("water_level_variable", dictionary)
interfaces_variable = get_dict_element("interfaces_variable", dictionary)
input_variable_names: List[str] = [
get_dict_element("input_variable", dictionary),
bed_level_variable,
water_level_variable,
interfaces_variable,
]
output_variable_name: str = get_dict_element("output_variable", dictionary)
description: str = get_dict_element("description", dictionary, False) or ""
rule_data = DepthAverageRuleData(
name,
input_variable_names,
)
rule_data.output_variable = output_variable_name
rule_data.description = description
return rule_data
rule_type_name: str
property
readonly
Type name for the rule
parse_dict(self, dictionary, logger)
Parses the provided dictionary to a IRuleData
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dictionary |
Dict[str, Any] |
Dictionary holding the values for making the rule |
required |
Returns:
Type | Description |
---|---|
RuleBase |
Rule based on the provided data |
Source code in parsers/parser_depth_average_rule.py
def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData:
"""Parses the provided dictionary to a IRuleData
Args:
dictionary (Dict[str, Any]): Dictionary holding the values
for making the rule
Returns:
RuleBase: Rule based on the provided data
"""
name: str = get_dict_element("name", dictionary)
bed_level_variable = get_dict_element("bed_level_variable", dictionary)
water_level_variable = get_dict_element("water_level_variable", dictionary)
interfaces_variable = get_dict_element("interfaces_variable", dictionary)
input_variable_names: List[str] = [
get_dict_element("input_variable", dictionary),
bed_level_variable,
water_level_variable,
interfaces_variable,
]
output_variable_name: str = get_dict_element("output_variable", dictionary)
description: str = get_dict_element("description", dictionary, False) or ""
rule_data = DepthAverageRuleData(
name,
input_variable_names,
)
rule_data.output_variable = output_variable_name
rule_data.description = description
return rule_data