Module rollup_cascade.manager
define RollupCascadeManager class as top level manager for all cascade/rollup operations for all tables across a single section. See ../specs/table_specs.py.
Classes
class RollupCascadeManager (*args: RollupCascadeSpec, collapse_all: bool = True)
-
Container for the set of rollup and cascade settings for all of the tables in a given section. rollup_casc_ref_instance[table_name] returns the combined rollup and cascade settings from all specs in which the specified table appears.
Args
*args
:tuple[RollupCascadeSpec, …]
- RollupCascadeSpec instances shared between a common set of tables (i.e. those of a section)
KwArgs
collapse_all
:bool
- If True, all tables will have a default rollup
operation that rolls up any row with more blanks than the previous
row. Default is True. Replaces legacy
table_utils.collapse_dict()
functionality.
Methods
def cascade(self, table_name: str, table: dict[str, list[str]]) ‑> dict[str, list[str]]
-
Perform all cascading operations defined for the supplied table_name.
Args
table_name
- name of the table currently processing
table
- dict of lists of strings representing table rows
Returns
dict[str, list[str]]
- dict of lists of strings representing table rows with values cascaded as specified in cascade_columns
def find_cascades(self, table_name: str, table: dict[str, list[str]]) ‑> list[CascadeColumn]
-
Finds the CascadeColumns defined for this table_name and filters them according to the column names in header. See self._column_check().
Args
table_name
- name of the table currently processing
table
- dict of lists of strings representing table rows
Returns
list[CascadeColumn]
- the cascades to perform for this table instance.
def find_rollups(self, table_name: str, pre_cascade: bool, table: dict[str, list[str]]) ‑> list[RollupColumn]
-
Finds the RollupColumns defined for this table_name and filters them according to the column names in header (see self._column_check()) and whether or not cascade operations have already occurred.
Args
table_name
- name of the table currently processing
pre_cascade
- bool indicating whether cascades have occurred.
table
- dict of lists of strings representing table rows
Returns
list[CascadeColumn]
- the rollups to perform for this table instance.
def rollup(self, table_name: str, table: dict[str, list[str]], pre_cascade: bool = True) ‑> dict[str, list[str]]
-
Perform all rollup operations defined for the supplied table_name and cascade status (pre or post).
Args
table_name
- name of the table currently processing
table
- dict of lists of strings representing table rows
pre_cascade
:bool
- indicates whether this operation is ocurring before or after its sister operation cascade_column_values()
Returns
dict[str, list[str]]
- dict of lists of strings representing table rows with values cascaded as specified in cascade_columns
def rollup_cascade_rollup(self, table_name: str, table: dict[str, list[str]]) ‑> dict[str, list[str]]
-
Performs pre cascade rollup, cascade, and post cascade rollup in series.
Args
table_name
- name of the table currently processing
table
- dict of lists of strings representing table rows
roll_ref
- RollupCascadeManager defining rollup and cascade operations for all tables in this section.
Returns
dict[str, list[str]]
- dict of lists of strings representing table rows with values rolled up and cascaded as specified in roll_ref