Coder Social home page Coder Social logo

email-rules's Introduction

email-rules

email-rules is a repository to build Email Rules and Filters to help you organize your inbox. Documentation for the repository can be found here.

Table of Contents:

Purpose:

Rather than using the clunky UIs of multiple different email clients, email-rules enables you to write your rules/filters using Python and then generate client-compatible representations of your rules, so they can be enforced. This repository enables you to have a single source for all of your rules, and allows you to generate rules in a streamlined manner. Additionally, if you decide to switch email clients in the future, you will be able to copy over (or regenerate) all of your email rules without having to manually (and painstakingly) rewrite them for each email client you use.

Documentation:

Documentation outlining how to use this repository can be found here. I used the NumPy Documentation Standard to outline the functionality of my code, and used sphinx to generate the docs website.

Currently Supported Email Clients:

  • Gmail

While Gmail is the only supported email client right now, this will change in the future. See Email Clients to be Supported in the Future for more details.

Email Clients to be Supported in the Future:

  • Microsoft Outlook
  • Mac Mail

email-rules's People

Contributors

henryasa avatar

Watchers

 avatar

email-rules's Issues

FEAT: Look into `Coverage.py`

Description of the Proposed Feature or Change:

Look into Coverage.py

Useful Links and Documentation to Reference:

No response

Example Python Code of Intended Implementation and Feature:

No response

FEAT: Add Dependabot to Repository

Proposed new feature or change:

Add a dependabot.yml file to the repository and configure Dependabot to automatically run on the repository. Also related to #17 because Dependabot can handle the automatic version management.

Make Dependabot generate new Docs after a pull request is merged into the main branch. Then Dependabot should be able to merge these updated Docs to the main branch.

Docs to Reference for the project:

Resource Link
GitHub Documentation - Configuration options for the dependabot.yml file Link
GitHub Documentation - Managing pull requests for dependency updates Link
GitHub Documentation - Automating Dependabot with GitHub Actions Link

DOC: Streamline DOCSTRINGs for aliases

Issue with current documentation:

Update DOCSTRINGs for alias functions so that they are connected instead of independent of each other.

Where the issue is and what it impacts:

No response

FEAT: Create `JSON` parser to build rules from `JSON`s

Description of the Proposed Feature or Change:

A user should be able to build rules based on the structure of a JSON file. This could include reading emails from a JSON or applying labels based on the values of a JSON file.

Useful Links and Documentation to Reference:

No response

Example Python Code of Intended Implementation and Feature:

No response

FEAT: Parameterize `PyTest` Tests

Proposed new feature or change:

Brief Description

PyTest test cases should be parameterized (so they can be used across rule types without requiring copying and pasting the test files).

Useful Documentation:

Coding Example of a Parametrized Test Case:

Python Code:

import pytest

testdata = [
    (10, 6, 4),
    (12, 20, -8),
]

@pytest.mark.parametrize("a,b,expected", testdata, ids=["Positive", "Negative"])
def test_subtraction(a, b, expected):
    difference = a - b
    assert difference == expected

Shell:

$ pytest test_time.py --collect-only
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 2 items

<Module test_subtraction.py>
  <Function test_subtraction[Positive]>
  <Function test_subtraction[Negative]>

BUG: Adjust `rule.add_attribute()` to accept multiple attributes at a time

Rather than requiring rule.add_attribute() to only accept two strings (corresponding to an attribute's name and its value), use **args or **kwargs (research how these work) to accept a dictionary of inputs where the keys of this dictionary correspond to the attribute's name and the values correspond to the value.

DOC: Add example code to DOCSTRINGs

Issue with current documentation:

Most functions in the Rule class are impacted by this issue. Add sample code to the DOCSTRING to show how the function behaves and how it should be used.

Where the issue is and what it impacts:

gmail_rules/rules/rule.py
gmail_rules/rules/copy_to.py
gmail_rules/rules/move_to.py
gmail_rules/actions/rule_collection.py
gmail_rules/utils/

BUG: `Rule_Collection` may include non-`Rule` objects if they appear in a later index of the `rules_to_add` list

Describe the issue:

If Rule_Collection.add_rule(rules_to_add) is called and rules_to_add is a list containing a Rule object in its first index but non-Rule objects in any other index, the Rule_Collection adds these anyway. In this situation, it should report an error and tell the user that one of the items passed into it is a non-Rule object.

Reproduce the code example:

def add_rule(self, rules_to_add: _R.Rule | list[_R.Rule]):
    try:
        if isinstance(rules_to_add, _R.Rule):
            rules_to_add = [rules_to_add]
        elif isinstance(rules_to_add[0], _R.Rule):
            pass
        else:
            raise TypeError(f"rule_to_add is not of type Rule or a list of Rules.  It is of type {type(rules_to_add)}")

    except TypeError:
        raise TypeError(f"rule_to_add is not of type Rule or a list of Rules.  It is of type {type(rules_to_add)}")

    for rule in rules_to_add:
        if rule.name in self.rules_dict:
            raise KeyError(f"{rule.name} is already in the collection of rules.  Use update_rule() to change the value of this rule")
        else:
            self.rules_list.append(rule)
            self.rules_dict[rule.name] = rule

add_rule([Rule("proper rule"), Rule("another rule"), tuple("not a rule")])

Error message:

No Error message, which is the problem.

Screenshots

No response

OS

Mac

BUG: Add DOCSTRINGs for example code

Describe the issue:

Include Typing docs and rebuild sphinx-docs.

Reproduce the code example:

No response

Error message:

No response

Screenshots

No response

OS

Mac

BUG: `Rule`s with the same name result in `KeyError` when both are added to a `Rule_Collection`

Describe the issue:

Use the id() function to define the key values of a Rule object in a Rule_Collection rather than a Rule's name. id(Rule) returns a unique value (integer) for each object, so no two unique Rules will have the same id() value.
However, two rules may have the same name, so even if the rules are different (have different attributes and serve different purposes), if they have the same name (which is also possible because they may both be unnamed and just use the default name), then there will be an error in the Rule_Collection.

Reproduce the code example:

from gmail_rules.rules import Rule
from gmail_rules.actions import Rule_Collection

rule_1 = Rule(rule_name="Mango")
rule_2 = Rule(rule_name="Mango")

rule_collection_1 = Rule_Collection()
rule_collection_1.add_rule(rule_1)
rule_collection_2.add_rule(rule_2)

Error message:

KeyError: 'Mango is already in the collection of rules.  Use update_rule() to change the value of this rule'

Screenshots

No response

OS

Mac

FEAT: Add versioning to the repository

Proposed new feature or change:

Add versioning and Changelogs and automatic changelog building to the repository to track adjustments between major versions.

FEAT: Set up Releasing and `CHANGELOG`

Description of the Proposed Feature or Change:

It would be cool to create a Release of this package and set up a CHANGELOG so changes between releases are automatically captured and recorded.

Useful Links and Documentation to Reference:

Example Python Code of Intended Implementation and Feature:

No response

FEAT: Add multiple labels to a single rule

Proposed new feature or change:

Even though Gmail doesn't correctly parse rules with multiple labels, a Rule object should be able to store multiple attributes for a label, and then build multiple versions of itself, each corresponding to the exact same rule but applying that rule to another label.

FEAT: Add AI to the Repo

Description of the Proposed Feature or Change:

Look at Sanebox and add AI to the repo to automatically build categories.

Useful Links and Documentation to Reference:

Example Python Code of Intended Implementation and Feature:

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.