Report¶
Data models for report production.
ActivityColumnMetric
dataclass
¶
This class provides granular control of the metric applied in each activity's column.
is_valid ¶
Checks if the activity column metric is valid.
Returns:
Type | Description |
---|---|
bool
|
True if the activity column metric is valid else False. |
Source code in src/cplus_plugin/models/report.py
ActivityContextInfo
dataclass
¶
Contains information about an activity for use in an expression context.
BaseReportContext
dataclass
¶
Common context information for generating a scenario report.
MetricColumn
dataclass
¶
MetricColumn(name, header, expression, alignment=QtCore.Qt.AlignHCenter, auto_calculated=False, format_as_number=True, number_formatter=QgsFallbackNumericFormat)
This class contains information required to create custom columns for the activity table in a scenario analysis report.
create_default_column
staticmethod
¶
Creates a default metric column.
:py:attr:~format_as_number
is set to True and
:py:attr:~number_formatter
is set to two decimals
places with a thousands' comma separator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Unique column name. |
required |
header |
str
|
Label that will be used in the activity metrics table. |
required |
expression |
str
|
Column expression. Default is an empty string. |
''
|
Returns:
Type | Description |
---|---|
MetricColumn
|
Metric column object. |
Source code in src/cplus_plugin/models/report.py
default_formatter
staticmethod
¶
Returns a default number formatter with two decimals places and a comma for thousands' separator.
Returns:
Type | Description |
---|---|
QgsNumericFormat
|
Basic number formatter. |
Source code in src/cplus_plugin/models/report.py
to_qgs_column ¶
Convenience function that converts this object to a QgsLayoutTableColumn for use in a QgsLayoutTable.
Returns:
Type | Description |
---|---|
QgsLayoutTableColumn
|
A layout column object containing the heading, horizontal alignment and width specified. |
Source code in src/cplus_plugin/models/report.py
MetricConfiguration
dataclass
¶
Container for metric column and activity column metric data models.
activities
property
¶
Gets the activity models in the configuration.
Returns:
Type | Description |
---|---|
typing.List[Activity]
|
Activity models in the configuration. |
create
staticmethod
¶
Creates an empty metric configuration.
Returns:
Type | Description |
---|---|
MetricConfiguration
|
An empty metric configuration. |
find ¶
Returns a matching activity column metric model for the activity with the given UUID and the corresponding metric column name or header label.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_id |
str
|
The activity's unique identifier. |
required |
name_header |
str
|
The metric column name or header to match. |
required |
Returns:
Type | Description |
---|---|
typing.Optional[ActivityColumnMetric]
|
Matching column metric or None if not found. |
Source code in src/cplus_plugin/models/report.py
is_valid ¶
Checks the validity of the configuration.
It verifies if the number of metric columns matches the column mappings for activity metrics.
Returns:
Type | Description |
---|---|
bool
|
True if the configuration is valid, else False. |
Source code in src/cplus_plugin/models/report.py
MetricConfigurationProfile
dataclass
¶
Profile with unique identifiers for a metrics configuration.
id
property
¶
Gets a cleaned profile name that has been stripped of spaces, special characters and in lower case.
Returns:
Type | Description |
---|---|
str
|
Cleaned version of the |
is_valid ¶
Checks if the profile is valid.
Checks if the name is specified or if the metric configuration is valid.
Returns:
Type | Description |
---|---|
bool
|
True if the profile is valid else False. |
Source code in src/cplus_plugin/models/report.py
MetricProfileCollection
dataclass
¶
Collection of MetricConfigurationProfile
objects.
identifiers
property
¶
Gets a collection of profile IDs and corresponding names.
Invalid profiles are excluded from the collection.
Returns:
Type | Description |
---|---|
dict
|
A collection of profile IDs and corresponding names. |
add_profile ¶
Add a metric profile to the collection.
It checks if there is an existing profile with a similar ID and if the profile is valid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profile |
MetricConfigurationProfile
|
Metric profile to be added to the collection. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the metric profile was successfully added else False if the profile is invalid or there exists one with a similar ID in the collection. |
Source code in src/cplus_plugin/models/report.py
get_current_profile ¶
Helper function that retrieves the current metric profile if it has been specified in the attribute.
Returns:
Type | Description |
---|---|
MetricConfigurationProfile
|
Current metric profile object or None if not specified or not found in the collection. |
Source code in src/cplus_plugin/models/report.py
get_profile ¶
Gets a metric profile with the given ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profile_id |
str
|
ID of the metric profile to retrieve. |
required |
Returns:
Type | Description |
---|---|
MetricConfigurationProfile
|
Metric profile matching the given ID or None if not found. |
Source code in src/cplus_plugin/models/report.py
profile_exists ¶
Checks if a profile with the given ID exists in the collection.
Returns:
Type | Description |
---|---|
bool
|
True if the profile ID exists else False. |
Source code in src/cplus_plugin/models/report.py
remove_profile ¶
Remove a metric profile from the collection.
Returns:
Type | Description |
---|---|
bool
|
True if the profile was successfully removed else False if the profile with the given ID does not exist in the collection. |
Source code in src/cplus_plugin/models/report.py
MetricType ¶
Bases: IntEnum
Type of metric or expression.
from_int
staticmethod
¶
Creates the metric type enum from the corresponding int equivalent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
int_enum |
int
|
Integer representing the metric type. |
required |
Returns:
Type | Description |
---|---|
MetricType
|
Metric type enum corresponding to the given int else unknown if not found. |
Source code in src/cplus_plugin/models/report.py
RepeatAreaDimension
dataclass
¶
Contains information for rendering repeat model items such as scenarios or activities in a CPlus repeat item.
ReportContext
dataclass
¶
ReportResult
dataclass
¶
Detailed result information from a report generation run.
pdf_path
property
¶
Returns the absolute path to the PDF file if the process completed successfully.
Caller needs to verify if the file actually exists in the given location.
:returns: Absolute path to the PDF file if the process completed successfully else an empty string.
ReportSubmitStatus
dataclass
¶
Result of report submission process.
ScenarioAreaInfo
dataclass
¶
Contains information on the result of calculating a scenario's area.
ScenarioComparisonReportContext
dataclass
¶
Bases: BaseReportContext
Contextual information related to the generation of scenario comparison report.