Added pytest and broke up the consumer into file and mail

This commit is contained in:
Daniel Quinn 2016-02-05 00:23:36 +00:00
parent 3bc89d23c8
commit d8ad6b589b
12 changed files with 381 additions and 44 deletions

View File

@ -12,10 +12,11 @@ from PIL import Image
from django.conf import settings
from django.utils import timezone
from django.template.defaultfilters import slugify
from paperless.db import GnuPG
from ..models import Tag, Document
from ..models import Sender, Tag, Document
from ..languages import ISO639
@ -31,6 +32,19 @@ class Consumer(object):
OCR = pyocr.get_available_tools()[0]
DEFAULT_OCR_LANGUAGE = settings.OCR_LANGUAGE
REGEX_TITLE = re.compile(
r"^.*/(.*)\.(pdf|jpe?g|png|gif|tiff)$",
flags=re.IGNORECASE
)
REGEX_SENDER_TITLE = re.compile(
r"^.*/(.*) - (.*)\.(pdf|jpe?g|png|gif|tiff)",
flags=re.IGNORECASE
)
REGEX_SENDER_TITLE_TAGS = re.compile(
r"^.*/(.*) - (.*) - ([a-z\-,])\.(pdf|jpe?g|png|gif|tiff)",
flags=re.IGNORECASE
)
def __init__(self, verbosity=1):
self.verbosity = verbosity
@ -105,13 +119,48 @@ class Consumer(object):
# Strip out excess white space to allow matching to go smoother
return re.sub(r"\s+", " ", r)
def _guess_file_attributes(self, doc):
raise NotImplementedError(
"At the very least a consumer should determine the file type.")
def _guess_attributes_from_name(self, parseable):
"""
We use a crude naming convention to make handling the sender, title, and
tags easier:
"<sender> - <title> - <tags>.<suffix>"
"<sender> - <title>.<suffix>"
"<title>.<suffix>"
"""
def get_sender(sender_name):
return Sender.objects.get_or_create(
name=sender_name, defaults={"slug": slugify(sender_name)})[0]
def get_tags(tags):
r = []
for t in tags.split(","):
r.append(
Tag.objects.get_or_create(slug=t, defaults={"name": t})[0])
return r
# First attempt: "<sender> - <title> - <tags>.<suffix>"
m = re.match(self.REGEX_SENDER_TITLE_TAGS, parseable)
if m:
return (
get_sender(m.group(1)),
m.group(2),
get_tags(m.group(3)),
m.group(4)
)
# Second attempt: "<sender> - <title>.<suffix>"
m = re.match(self.REGEX_SENDER_TITLE, parseable)
if m:
return get_sender(m.group(1)), m.group(2), [], m.group(3)
# That didn't work, so we assume sender and tags are None
m = re.match(self.REGEX_TITLE, parseable)
return None, m.group(1), [], m.group(2)
def _store(self, text, doc):
sender, title, file_type = self._guess_file_attributes(doc)
sender, title, file_type = self._guess_attributes_from_name(doc)
lower_text = text.lower()
relevant_tags = [t for t in Tag.objects.all() if t.matches(lower_text)]

View File

@ -2,10 +2,8 @@ import os
import re
from django.conf import settings
from django.template.defaultfilters import slugify
from ..models import Sender
from . import Consumer, OCRError
from .base import Consumer, OCRError
class FileConsumerError(Exception):
@ -16,11 +14,6 @@ class FileConsumer(Consumer):
CONSUME = settings.CONSUMPTION_DIR
PARSER_REGEX_TITLE = re.compile(
r"^.*/(.*)\.(pdf|jpe?g|png|gif|tiff)$", flags=re.IGNORECASE)
PARSER_REGEX_SENDER_TITLE = re.compile(
r"^.*/(.*) - (.*)\.(pdf|jpe?g|png|gif|tiff)", flags=re.IGNORECASE)
def __init__(self, *args, **kwargs):
Consumer.__init__(self, *args, **kwargs)
@ -47,7 +40,7 @@ class FileConsumer(Consumer):
if not os.path.isfile(doc):
continue
if not re.match(self.PARSER_REGEX_TITLE, doc):
if not re.match(self.REGEX_TITLE, doc):
continue
if doc in self._ignore:
@ -85,22 +78,3 @@ class FileConsumer(Consumer):
self.stats[doc] = t
return False
def _guess_file_attributes(self, doc):
"""
We use a crude naming convention to make handling the sender and title
easier:
"<sender> - <title>.<suffix>"
"""
# First we attempt "<sender> - <title>.<suffix>"
m = re.match(self.PARSER_REGEX_SENDER_TITLE, doc)
if m:
sender_name, title, file_type = m.group(1), m.group(2), m.group(3)
sender, __ = Sender.objects.get_or_create(
name=sender_name, defaults={"slug": slugify(sender_name)})
return sender, title, file_type
# That didn't work, so we assume sender is None
m = re.match(self.PARSER_REGEX_TITLE, doc)
return None, m.group(1), m.group(2)

View File

@ -1,6 +1,10 @@
import datetime
import email
import imaplib
from base64 import b64decode
from io import BytesIO
from django.conf import settings
from . import Consumer
@ -49,7 +53,8 @@ class MailConsumer(Consumer):
def consume(self):
if self._enabled:
self.get_messages()
for message in self.get_messages():
pass
self.last_checked = datetime.datetime.now()
@ -58,12 +63,64 @@ class MailConsumer(Consumer):
self._connect()
self._login()
for message in self._fetch():
print(message) # Now we have to do something with the attachment
messages = []
for data in self._fetch():
message = self._parse_message(data)
if message:
messages.append(message)
self._connection.expunge()
self._connection.close()
self._connection.logout()
def _guess_file_attributes(self, doc):
return None, None, "jpg"
return messages
@staticmethod
def _parse_message(data):
"""
Cribbed heavily from
https://www.ianlewis.org/en/parsing-email-attachments-python
"""
r = []
message = email.message_from_string(data)
for part in message.walk():
content_disposition = part.get("Content-Disposition")
if not content_disposition:
continue
dispositions = content_disposition.strip().split(";")
if not dispositions[0].lower() == "attachment":
continue
file_data = part.get_payload()
attachment = BytesIO(b64decode(file_data))
attachment.content_type = part.get_content_type()
attachment.size = len(file_data)
attachment.name = None
attachment.create_date = None
attachment.mod_date = None
attachment.read_date = None
for param in dispositions[1:]:
name, value = param.split("=")
name = name.lower()
if name == "filename":
attachment.name = value
elif name == "create-date":
attachment.create_date = value
elif name == "modification-date":
attachment.mod_date = value
elif name == "read-date":
attachment.read_date = value
r.append({
"subject": message.get("Subject"),
"attachment": attachment,
})
return r

View File

@ -157,5 +157,9 @@ class Document(models.Model):
@property
def parseable_file_name(self):
if self.sender and self.title:
return "{} - {}.{}".format(self.sender, self.title, self.file_types)
tags = ",".join([t.slug for t in self.tags.all()])
if tags:
return "{} - {} - {}.{}".format(
self.sender, self.title, tags, self.file_type)
return "{} - {}.{}".format(self.sender, self.title, self.file_type)
return os.path.basename(self.source_path)

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

View File

@ -0,0 +1,43 @@
import os
import magic
from hashlib import md5
from django.conf import settings
from django.test import TestCase
from ...consumers.mail import MailConsumer
class TestMailConsumer(TestCase):
def __init__(self, *args, **kwargs):
TestCase.__init__(self, *args, **kwargs)
self.sample = os.path.join(
settings.BASE_DIR,
"documents",
"tests",
"consumers",
"samples",
"mail.txt"
)
def test_parse(self):
consumer = MailConsumer()
with open(self.sample) as f:
messages = consumer._parse_message(f.read())
self.assertTrue(len(messages), 1)
self.assertEqual(messages[0]["subject"], "Test 0")
attachment = messages[0]["attachment"]
data = attachment.read()
self.assertEqual(
md5(data).hexdigest(), "7c89655f9e9eb7dd8cde8568e8115d59")
self.assertEqual(attachment.content_type, "application/pdf")
with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
self.assertEqual(m.id_buffer(data), "application/pdf")

View File

@ -0,0 +1,208 @@
Return-Path: <sender@example.com>
X-Original-To: sender@mailbox4.mailhost.com
Delivered-To: sender@mailbox4.mailhost.com
Received: from mx8.mailhost.com (mail8.mailhost.com [75.126.24.68])
by mailbox4.mailhost.com (Postfix) with ESMTP id B62BD5498001
for <sender@mailbox4.mailhost.com>; Thu, 4 Feb 2016 22:01:17 +0000 (UTC)
Received: from localhost (localhost.localdomain [127.0.0.1])
by mx8.mailhost.com (Postfix) with ESMTP id B41796F190D
for <sender@mailbox4.mailhost.com>; Thu, 4 Feb 2016 22:01:17 +0000 (UTC)
X-Spam-Flag: NO
X-Spam-Score: 0
X-Spam-Level:
X-Spam-Status: No, score=0 tagged_above=-999 required=3
tests=[RCVD_IN_DNSWL_NONE=-0.0001]
Received: from mx8.mailhost.com ([127.0.0.1])
by localhost (mail8.mailhost.com [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 3cj6d28FXsS3 for <sender@mailbox4.mailhost.com>;
Thu, 4 Feb 2016 22:01:17 +0000 (UTC)
Received: from smtp.mailhost.com (smtp.mailhost.com [74.55.86.74])
by mx8.mailhost.com (Postfix) with ESMTP id 527D76F1529
for <paperless@example.com>; Thu, 4 Feb 2016 22:01:17 +0000 (UTC)
Received: from [10.114.0.19] (nl3x.mullvad.net [46.166.136.162])
by smtp.mailhost.com (Postfix) with ESMTP id 9C52420C6FDA
for <paperless@example.com>; Thu, 4 Feb 2016 22:01:16 +0000 (UTC)
To: paperless@example.com
From: Daniel Quinn <sender@example.com>
Subject: Test 0
Message-ID: <56B3CA2A.6030806@example.com>
Date: Thu, 4 Feb 2016 22:01:14 +0000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
Thunderbird/38.5.0
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------090701020702030809070008"
This is a multi-part message in MIME format.
--------------090701020702030809070008
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
This is the test body.
--------------090701020702030809070008
Content-Type: application/pdf;
name="test0.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="test0.pdf"
JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0
ZURlY29kZT4+CnN0cmVhbQp4nFWLQQvCMAyF7/kVOQutSdeuHZSA0+3gbVDwIN6c3gR38e/b
bF4kkPfyvReyjB94IyFVF7pgG0ze4TLDZYevLamzPKEvEFqbMEZfq+WO+5GRHZbHNROLy+So
UfFi6g7/RyusEpUl9VsQxQTlHR2oV3wUEzOdhOnXG1aw/o1yK2cYCkww4RdbUCevCmVuZHN0
cmVhbQplbmRvYmoKCjMgMCBvYmoKMTM5CmVuZG9iagoKNSAwIG9iago8PC9MZW5ndGggNiAw
IFIvRmlsdGVyL0ZsYXRlRGVjb2RlL0xlbmd0aDEgMTA4MjQ+PgpzdHJlYW0KeJzlOWt0G9WZ
95uRbNmWLckPWY4SaRTFedmybI8T4rw8sS3ZiZ1YfqWSCbFkS7YEtiQkJSE8GlNeOQ5pUmh5
Zkt2l+XQNl3GhLaBpcWw0D19UGALLRRS0gM9nD0lxVBK9wCx97tXI0UJAc727L8d+c587/u9
7p0rOZXYEyJaMkV4Io1OBuLOqmqBEPJLQqB0dG9K2NRTsQHhM4Rw/zkWH5+870e7PiRE9Rgh
+Y+NT+wf+/b3e4YI0YYJKX41HAoEfx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IC8yQTY0RDMzNzRFQTVEODMwNTRDNEI2RDFEMUY4QzU1RQo+
PgpzdGFydHhyZWYKODAxOAolJUVPRgo=
--------------090701020702030809070008--

View File

@ -0,0 +1 @@
from .consumers.mail import TestMailConsumer

View File

@ -136,10 +136,9 @@ STATIC_URL = '/static/'
MEDIA_URL = "/media/"
#
# Paperless-specific stuffs
# Change these paths if yours are different
#
# ----------------------------------------------------------------------------
# The default language that tesseract will attempt to use when parsing
# documents. It should be a 3-letter language code consistent with ISO 639.
@ -180,3 +179,4 @@ MAIL_CONSUMPTION = {
# DON'T FORGET TO SET THIS as leaving it blank may cause some strang things with
# GPG, including an interesting case where it may "encrypt" zero-byte files.
PASSPHRASE = os.environ.get("PAPERLESS_PASSPHRASE")

4
src/pytest.ini Normal file
View File

@ -0,0 +1,4 @@
[pytest]
python_files=tests.py
DJANGO_SETTINGS_MODULE=paperless.settings