gmail_rules.actions.Rule_Collection#

class Rule_Collection(name: str = 'Rule Collection')[source]#

Bases: object

Collection of Rule that can be organized and stored together

Parameters:

name (str, optional) – Name of this collection of rules

Attributes:
final_string

Generates the final string representation of a collection of rules

Methods

add_rule(rule_to_add)

Alias for Rule_Collection.add_rules().

add_rules(rules_to_add)

Add Rule objects to a Rule_Collection

build_final_string([additional_comment])

Builds the final properly formatted collection of rules

Methods

add_rule

Alias for Rule_Collection.add_rules().

add_rules

Add Rule objects to a Rule_Collection

build_final_string

Builds the final properly formatted collection of rules

Attributes

final_string

Generates the final string representation of a collection of rules

name

str representing the name of the collection of rules

rules_list

list of Rule objects that will be included in a single file

rules_dict

dict where keys are a rule's title (rule_title) and the values are that rule

add_rule(rule_to_add: Rule) None[source]#

Alias for Rule_Collection.add_rules(). Adds Rule to a Rule_Collection

Parameters:

rules_to_add (list or tuple or set or frozenset or dict) – The Rule that should be added to the Rule_Collection

Raises:
  • KeyError – Raises a KeyError when a certain rule is already in the collection

  • TypeError – Raises a TypeError when a rule is not of type Rule

  • TypeError – Raises a TypeError if a rule is not an iterable of Rule

add_rules(rules_to_add: Rule | list | tuple | set | frozenset | dict) None[source]#

Add Rule objects to a Rule_Collection

Parameters:

rules_to_add (Rule or list or tuple or set or frozenset or dict) – The Rule (or Rule) that should be added to the Rule_Collection

Raises:
  • KeyError – Raises a KeyError when a certain rule is already in the collection

  • TypeError – Raises a TypeError when a rule is not of type Rule

  • TypeError – Raises a TypeError if a rule is not an iterable of Rule

build_final_string(additional_comment: str | None = None) str[source]#

Builds the final properly formatted collection of rules

Parameters:

additional_comment (str, optional) – Adds a final comment above the entire rule string, by default None

Returns:

final string representing all of the Rule in the collection

Return type:

str

property final_string: str#

Generates the final string representation of a collection of rules

Returns:

str representing the xmls of all the rules in this collection

Return type:

str

name#

str representing the name of the collection of rules

rules_dict: dict[str, Rule]#

dict where keys are a rule’s title (rule_title) and the values are that rule

rules_list: list[Rule]#

list of Rule objects that will be included in a single file