Skip to content

Commit

Permalink
🚀 release on PyPI.org
Browse files Browse the repository at this point in the history
  • Loading branch information
k8scat committed Feb 9, 2021
1 parent 86e31f6 commit 5a4f268
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

.venv
__pycache__
build
dist
*.egg-info

.index
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
<a href="https://gitee.com/hsowan/ForMaiR">码云</a>
</p>

## Usage
## Installation

### Install using `pip`

```bash
# clone repo
git clone [email protected]:k8scat/ForMaiR.git
cd ForMaiR
$ python3 -m pip install --user formair
```

# copy `template/config.yaml` as your own
cp template/config.yaml config.yaml
### Install using `git`

# init python3 environment
virtualenv -p python3 .venv
source .venv/bin/activate
```bash
$ git clone [email protected]:k8scat/ForMaiR.git
$ cd ForMaiR
$ python3 setup.py install
```

# install requirements
pip install -r requirements.txt
## Usage

Refer config: [template/config.yaml](https://github.com/k8scat/ForMaiR/blob/master/template/config.yaml)

```bash
$ formair # load config from ./config.yaml

# start forwarding emails by your custom rules
python main.py config.yaml
$ formair /path/to/config.yaml # load config from /path/to/config.yaml
```

## Custom rules
Expand Down
31 changes: 18 additions & 13 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,30 @@

自定义规则的邮件自动转发工具。

## 使用
## 安装

### 使用 `pip`

```bash
# 克隆代码仓
git clone [email protected]:hsowan/ForMaiR.git
cd ForMaiR
$ python3 -m pip install --user formair
```

# 从 template/config.yaml 复制一份配置文件
cp template/config.yaml config.yaml
### 使用 `git`

# 初始化 python3 的环境
virtualenv -p python3 .venv
source .venv/bin/activate
```bash
$ git clone [email protected]:k8scat/ForMaiR.git
$ cd ForMaiR
$ python3 setup.py install
```

# 安装依赖
pip install -r requirements.txt
## 使用

参考配置:[template/config.yaml](https://github.com/k8scat/ForMaiR/blob/master/template/config.yaml)

```bash
$ formair # 从 ./config.yaml 中加载配置

# 开始根据自定义的规则进行转发邮件
python main.py config.yaml
$ formair /path/to/config.yaml # 从 /path/to/config.yaml 中加载配置
```

## 自定义规则
Expand Down
7 changes: 5 additions & 2 deletions main.py → formair/formair.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
datefmt="%Y-%m-%d %H:%M:%S")

DEFAULT_INDEX_FILE = '.index'
DEFAULT_CONFIG_FILE = './config.yaml'


def init_pop3_server(config: dict) -> pop3.POP3:
Expand All @@ -38,7 +39,10 @@ def init_email_count(pop3_server: pop3.POP3) -> int:


def main():
config = load_config(sys.argv[1])
cfg_file = DEFAULT_CONFIG_FILE
if len(sys.argv) == 2:
cfg_file = sys.argv[1]
config = load_config(cfg_file)
index_file = config['index_file'] if config['index_file'] else DEFAULT_INDEX_FILE

pop3_server = init_pop3_server(config['pop3'])
Expand All @@ -54,5 +58,4 @@ def main():


if __name__ == '__main__':
assert len(sys.argv) == 2
main()
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import setuptools

with open("README.md", 'r', encoding="utf-8") as f:
long_description = f.read()

setuptools.setup(
name='formair',
version='1.2.0',
author='K8sCat',
author_email='[email protected]',
description='auto Forward eMails with custom Rules',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/k8scat/ForMaiR',
packages=setuptools.find_packages(),
entry_points={'console_scripts': ['formair = formair.formair:main']},
install_requires=['PyYaml'],
)

0 comments on commit 5a4f268

Please sign in to comment.