gmail_rules.rules.Copy_To#
- class Copy_To(rule_label: str | list, list_of_emails: list = [], rule_defaults: dict = {}, rule_name: str = '')[source]#
Bases:
Rule
Copy_To
rule object which is a sub-class ofRule
- Attributes:
final_rule_str
This is the final str that can be copied and pasted into an xml to define the rule
rule_attributes_xmls
Converts dict of rule attributes into dict of attributes where keys are in xml format
rule_attributes_xmls_str
Converts
dict
of rule attributes into ordered str for use in final xml
Methods
add_attribute
(name, value[, is_custom_attribute])Add an attribute to the mail rule
add_attributes
(attributes_to_add)Add multiple attributes to a Rule
add_label
(label)Alias for
Rule.add_label()
.add_labels
(labels)Adds labels to the mail rule
After all of the details of a rule are defined, this function is run to actually build the desired mail rule.
concatenate
(elements_input[, separator])Given a list of elements elements, this returns the concatenation of the elements with a separator separator between them (" OR " by default)
flatten_list
(list_to_flatten)Converts a list of lists into a single flat list
xml_format_rule_attribute
(name, value)Given an attribute name, its value, and an optional boolean determining whether this new attriute should be added to the list of attributes, this function properly builds and formats (and assigns) the defined attribute.
Initialize a
Copy_To
rule object which is a subclass ofRule
- Parameters:
rule_label (str or list) – This is the label that should be applied to emails that meet this rule’s criteria
list_of_emails (list, optional) – This is a list of email addresses that the mail rule should be applied to
rule_defaults (dict, optional) – This is a dictionary containing default rule attributes
- Attributes:
final_rule_str
This is the final str that can be copied and pasted into an xml to define the rule
rule_attributes_xmls
Converts dict of rule attributes into dict of attributes where keys are in xml format
rule_attributes_xmls_str
Converts
dict
of rule attributes into ordered str for use in final xml
Methods
add_attribute
(name, value[, is_custom_attribute])Add an attribute to the mail rule
add_attributes
(attributes_to_add)Add multiple attributes to a Rule
add_label
(label)Alias for
Rule.add_label()
.add_labels
(labels)Adds labels to the mail rule
After all of the details of a rule are defined, this function is run to actually build the desired mail rule.
concatenate
(elements_input[, separator])Given a list of elements elements, this returns the concatenation of the elements with a separator separator between them (" OR " by default)
flatten_list
(list_to_flatten)Converts a list of lists into a single flat list
xml_format_rule_attribute
(name, value)Given an attribute name, its value, and an optional boolean determining whether this new attriute should be added to the list of attributes, this function properly builds and formats (and assigns) the defined attribute.
Methods
Add an attribute to the mail rule
Add multiple attributes to a Rule
Alias for
Rule.add_label()
.Adds labels to the mail rule
After all of the details of a rule are defined, this function is run to actually build the desired mail rule.
Given a list of elements elements, this returns the concatenation of the elements with a separator separator between them (" OR " by default)
Converts a list of lists into a single flat list
Given an attribute name, its value, and an optional boolean determining whether this new attriute should be added to the list of attributes, this function properly builds and formats (and assigns) the defined attribute.
Attributes
This is the final str that can be copied and pasted into an xml to define the rule
Converts dict of rule attributes into dict of attributes where keys are in xml format
Converts
dict
of rule attributes into ordered str for use in final xmlThis is a list containing all of the labels that should be applied to this rule
This str is the title of the rule
This is a dict of all of the rule attributes that should be applied
Flattened list of emails that will be included in the mail rule
A str of the concatenated email addresses that this rule applies to
This is a str representing the top section of a mail rule that remains constant
This is a str representing how each mail rule will end
- add_attribute(name: str, value: str, is_custom_attribute: bool = False) None #
Add an attribute to the mail rule
- Parameters:
name (str) – Name of the attribute to add
value (str) – Value of the attribute
is_custom_attribute (bool, optional) – Defines whether the attribute being added is custom (use with caution), by default False. Use this with caution, as the mail rule interpreter may not be able to parse a rule with a custom attribute
- Raises:
- add_label(label: str) None #
Alias for
Rule.add_label()
. Adds labels to the mail rule
- build_rule() str #
After all of the details of a rule are defined, this function is run to actually build the desired mail rule. It takes an optional argument rule_name which is a str representing the name of the mail rule, but when the rule is parsed into Gmail, this gets ignored.
- concatenate(elements_input: list, separator: str = ' OR ') str #
Given a list of elements elements, this returns the concatenation of the elements with a separator separator between them (” OR “ by default)
- Parameters:
elements_input (list) – This is a list of items that should be concatenated together
separator (str, default = “ OR “, optional) – This is the string that will be used to separate individual elements, by default “ OR “
- Returns:
final_output – Returns a singular string containing all of the items in elements after being concatenated and separated with the separator
- Return type:
str
- property final_rule_str: str#
This is the final str that can be copied and pasted into an xml to define the rule
- Returns:
str representing the entire rule in xml format
- Return type:
- flatten_list(list_to_flatten: list) list #
Converts a list of lists into a single flat list
This function takes a list (of potentially nested lists) and recursively flattens the list so that it is just a single list of elements that are not of type list
- Parameters:
list_to_flatten (list) – Input list (or list of lists) to be flattened
- Returns:
Returns a final flat list that does not contain any nested lists
- Return type:
- rule_attributes: dict[str, str]#
This is a dict of all of the rule attributes that should be applied
- property rule_attributes_xmls: dict#
Converts dict of rule attributes into dict of attributes where keys are in xml format
- Returns:
rule_attribute_xmls – Dictionary where keys are the attribute and values are the xml representation of the attribute
- Return type:
dict
- property rule_attributes_xmls_str: str#
Converts
dict
of rule attributes into ordered str for use in final xml
This is a str representing how each mail rule will end
- xml_format_rule_attribute(name: str, value: str) str #
Given an attribute name, its value, and an optional boolean determining whether this new attriute should be added to the list of attributes, this function properly builds and formats (and assigns) the defined attribute.
- Parameters:
name (str) – This is the name of the attribute to define (defined by Google’s docs)
value (str) – This is the value of the desired attribute
- Returns:
rule_line – Returns the properly formatted attribute
- Return type:
str