From 73e1eb07a3061a3f7eeaac018bd17506b2f45885 Mon Sep 17 00:00:00 2001 From: Diogo Alves Date: Thu, 16 Sep 2021 11:36:21 -0300 Subject: [PATCH] Release to pypi --- .editorconfig | 4 + .gitignore | 6 +- MANIFEST.in | 1 + README.md | 86 +++++++++++++++++++ ...tachments_extractor.py => eml_extractor.py | 2 +- pyproject.toml | 6 ++ setup.cfg | 36 ++++++++ setup.py | 3 + 8 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 MANIFEST.in create mode 100644 README.md rename eml_attachments_extractor.py => eml_extractor.py (98%) create mode 100644 pyproject.toml create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.editorconfig b/.editorconfig index dcd114a..4f93263 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,7 @@ trim_trailing_whitespace = true indent_style = space indent_size = 4 max_line_length = 119 + +[*.toml] +indent_size = 2 +indent_style = space diff --git a/.gitignore b/.gitignore index 7bfcd7a..41a47af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ __pycache__/ -*.pyc \ No newline at end of file +*.pyc + +build/ +dist/ +*.egg-info/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..1aba38f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include LICENSE diff --git a/README.md b/README.md new file mode 100644 index 0000000..68a1907 --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +# EML Extractor + +EML Extractor is a CLI tool to extract attachments from .eml files (email messages saved as files). + + +## Features + +* Find .eml files (recursively or not) in a selected folder; +* Select individuals .eml files to extraction; +* Save all attachments in a single main folder; +* Organize the attachments by email subject subfolder. + + +## Requirements + +Python 3.6+ + + +## Installation + +```console +$ pip install eml-extractor +``` + + +## Usage + +By default, the current working directory is used as the source for .eml files as well as destination for extracted attachments. You can set different optional arguments to change this behavior: + +```console +usage: eml-extractor [OPTIONS] + +Extracts attachments from .eml files + +optional arguments: + -h, --help show this help message and exit + -s PATH, --source PATH + the directory containing the .eml files to extract + attachments (default: current working directory) + -r, --recursive allow recursive search for .eml files under SOURCE + directory + -f FILE [FILE ...], --files FILE [FILE ...] + specify an .eml file or a list of .eml files to extract + attachments + -d PATH, --destination PATH + the directory to extract attachments to (default: + current working directory) +``` + + +## Examples + +### 1. Find all .eml files in current working dir, extract the attachments and save them in the same dir: +```console +$ eml-extractor +``` + +The command above is equivalent to: +```console +$ eml-extractor --source . --destination . +``` + +### 2. Set another path for searching .eml files: +```console +$ eml-extractor --source /path/to/eml/files/ +``` + +### 3. Allow recursive searching: +```console +$ eml-extractor --source /path/to/eml/files/ --recursive +``` + +### 4. Define manually from which files the attachments will be extracted: +```console +$ eml-extractor --files /path/to/file1.eml /path/to/file2.eml +``` + +### 5. Change the path where to save the extracted attachments: +```console +$ eml-extractor --destination /path/to/extracted/attachments/ +``` + + +## License + +This project is licensed under the terms of the [MIT License](https://github.com/diogo-alves/eml-extractor/blob/main/LICENSE). diff --git a/eml_attachments_extractor.py b/eml_extractor.py similarity index 98% rename from eml_attachments_extractor.py rename to eml_extractor.py index 4a78fd6..dc2f8bb 100644 --- a/eml_attachments_extractor.py +++ b/eml_extractor.py @@ -56,7 +56,7 @@ def check_path(arg_value: str) -> Path: def main(): parser = ArgumentParser( - usage='python3 %(prog)s [OPTIONS]', + usage='%(prog)s [OPTIONS]', description='Extracts attachments from .eml files' ) # force the use of --source or --files, not both diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4789c9a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools >= 42", + "wheel", +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..d66f0cc --- /dev/null +++ b/setup.cfg @@ -0,0 +1,36 @@ +[metadata] +name = eml-extractor +version = 0.1.1 +author = Diogo Alves +author_email = diogo.alves.ti@gmail.com +description = A CLI tool to extract attachments from .eml files (email messages saved as files) +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/diogo-alves/eml-extractor +platform = any +keywords = cli, eml, email, attachments, extract +license = MIT +license_files = LICENSE +classifiers = + Environment :: Console + Programming Language :: Python + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Operating System :: OS Independent + Intended Audience :: End Users/Desktop + License :: OSI Approved :: MIT License + Natural Language :: English + Topic :: Communications :: Email + Topic :: Utilities + +[options] +py_modules = eml_extractor +python_requires = >=3.6 +packages = find: + +[options.entry_points] +console_scripts = + eml-extractor = eml_extractor:main diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6068493 --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup()