Skip to content

Commit

Permalink
Merge 74b96bc into 6e6a30c
Browse files Browse the repository at this point in the history
  • Loading branch information
fedelemantuano committed Mar 19, 2024
2 parents 6e6a30c + 74b96bc commit 5554336
Show file tree
Hide file tree
Showing 41 changed files with 369 additions and 457 deletions.
3 changes: 0 additions & 3 deletions .bettercodehub.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .coveragerc

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/main.yml
@@ -0,0 +1,58 @@
name: Python application

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y libemail-outlook-message-perl
pip install ".[dev, test]"
export PERL_MM_USE_DEFAULT=1
sudo cpan -f -i Email::Outlook::Message
- name: Run tests
run: |
pytest
python -m mailparser -v
python -m mailparser -h
mail-parser -f tests/mails/mail_malformed_3 -j
cat tests/mails/mail_malformed_3 | mail-parser -k -j
- name: Report to Coveralls
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: |
python -m build
- name: Upload artifacts
if: matrix.python-version == '3.10'
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/mail-parser-*.tar.gz
dist/mail_parser-*.whl
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,3 +14,4 @@ venv27
venv3
venv-mailparser
report/
junit.xml
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,29 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=5000']
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: detect-aws-credentials
args: ["--allow-missing-credentials"]
- id: detect-private-key
- id: mixed-line-ending
- id: check-ast

#- repo: https://github.com/astral-sh/ruff-pre-commit
# # Ruff version.
# rev: v0.3.2
# hooks:
# # Run the linter.
# - id: ruff
# args: [ --fix ]
# # Run the formatter.
# - id: ruff-format
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

61 changes: 17 additions & 44 deletions Makefile
Expand Up @@ -29,54 +29,27 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT"
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
clean-build: ## remove all build files
find . -type d -name "build" -exec rm -rf {} +
find . -type d -name "dist" -exec rm -rf {} +

clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-tests: ## remove test and coverage artifacts
find . -type f -name "*.log" -delete
find . -type f -name "coverage.xml" -delete
find . -type f -name "junit.xml" -delete
find . -type f -name ".coverage" -delete
find . -type d -name ".pytest_cache" -exec rm -rf {} +
find . -type d -name "htmlcov" -exec rm -rf {} +
find . -type d -name ".mypy_cache" -exec rm -rf {} +
find . -type d -name "__pycache__" -exec rm -rf {} +

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-all: clean-tests clean-build ## remove all tests and build files

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
test: clean-tests ## run tests quickly with the default Python
pytest

lint: ## check style with flake8
flake8 mailparser tests

test: ## run tests quickly with the default Python
python -m unittest discover -s tests -f -v

test-all: ## run tests on every Python version with tox
tox

# docs: ## generate Sphinx HTML documentation, including API docs
# rm -f docs/mailparser.rst
# rm -f docs/modules.rst
# sphinx-apidoc -o docs/ mailparser
# $(MAKE) -C docs clean
# $(MAKE) -C docs html
# $(BROWSER) docs/_build/html/index.html

# servedocs: docs ## compile the docs watching for changes
# watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
dist: clean-all ## builds source and wheel package
python -m build

release: dist ## package and upload a release
twine upload dist/*

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist

install: clean ## install the package to the active Python's site-packages
python setup.py install
128 changes: 0 additions & 128 deletions Pipfile.lock

This file was deleted.

25 changes: 10 additions & 15 deletions README.md
@@ -1,18 +1,15 @@
[![PyPI version](https://badge.fury.io/py/mail-parser.svg)](https://badge.fury.io/py/mail-parser)
[![Build Status](https://travis-ci.org/SpamScope/mail-parser.svg?branch=develop)](https://travis-ci.org/SpamScope/mail-parser)
[![Coverage Status](https://coveralls.io/repos/github/SpamScope/mail-parser/badge.svg?branch=develop)](https://coveralls.io/github/SpamScope/mail-parser?branch=develop)
[![BCH compliance](https://bettercodehub.com/edge/badge/SpamScope/mail-parser?branch=develop)](https://bettercodehub.com/)
[![](https://images.microbadger.com/badges/image/fmantuano/spamscope-mail-parser.svg)](https://microbadger.com/images/fmantuano/spamscope-mail-parser "Get your own image badge on microbadger.com")

![SpamScope](https://raw.githubusercontent.com/SpamScope/spamscope/develop/docs/logo/spamscope.png)

# mail-parser

mail-parser is not only a wrapper for [email](https://docs.python.org/2/library/email.message.html) Python Standard Library.
`mail-parser` is not only a wrapper for [email](https://docs.python.org/2/library/email.message.html) Python Standard Library.
It give you an easy way to pass from raw mail to Python object that you can use in your code.
It's the key module of [SpamScope](https://github.com/SpamScope/spamscope).

mail-parser can parse Outlook email format (.msg). To use this feature, you need to install `libemail-outlook-message-perl` package. For Debian based systems:
`mail-parser` can parse Outlook email format (.msg). To use this feature, you need to install `libemail-outlook-message-perl` package. For Debian based systems:

```
$ apt-get install libemail-outlook-message-perl
Expand All @@ -24,18 +21,16 @@ For more details:
$ apt-cache show libemail-outlook-message-perl
```

mail-parser supports Python 3.
`mail-parser` supports Python 3.

The support to Python 2 has been dropped from version 4.0.0.


# Apache 2 Open Source License
mail-parser can be downloaded, used, and modified free of charge. It is available under the Apache 2 license.
`mail-parser` can be downloaded, used, and modified free of charge. It is available under the Apache 2 license.

## Support the project

**Dogecoin**: `DAUbDUttkf8WN1kwP9YYQQKyEJYY2WWtEG`

[![Donate with Bitcoin](https://en.cryptobadges.io/badge/big/1BCJ8wok4DNW8KbdL8H3VwZviXAWibhEPe)](https://en.cryptobadges.io/donate/1BCJ8wok4DNW8KbdL8H3VwZviXAWibhEPe)

[![Donate](https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif "Donate")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VEPXYP745KJF2)

# mail-parser on Web
Expand All @@ -46,7 +41,7 @@ mail-parser can be downloaded, used, and modified free of charge. It is availabl

# Description

mail-parser takes as input a raw email and generates a parsed object. The properties of this object are the same name of
`mail-parser` takes as input a raw email and generates a parsed object. The properties of this object are the same name of
[RFC headers](https://www.iana.org/assignments/message-headers/message-headers.xhtml):

- bcc
Expand Down Expand Up @@ -100,7 +95,7 @@ The `received` header is parsed and splitted in hop. The fields supported are:
- with


mail-parser can detect defect in mail:
`mail-parser` can detect defect in mail:
- [defects](https://docs.python.org/2/library/email.message.html#email.message.Message.defects): mail with some not compliance RFC part

All properties have a JSON and raw property that you can get with:
Expand Down Expand Up @@ -136,7 +131,7 @@ Clone repository
git clone https://github.com/SpamScope/mail-parser.git
```

and install mail-parser with `setup.py`:
and install `mail-parser` with `setup.py`:

```
$ cd mail-parser
Expand Down Expand Up @@ -260,7 +255,7 @@ From [raw mail](https://gist.github.com/fedelemantuano/5dd702004c25a46b2bd60de21

# Exceptions

Exceptions hierarchy of mail-parser:
Exceptions hierarchy of `mail-parser`:

```
MailParserError: Base MailParser Exception
Expand Down

0 comments on commit 5554336

Please sign in to comment.