diff options
| author | Aurélien Bompard <aurelien@bompard.org> | 2012-10-26 12:38:52 +0200 |
|---|---|---|
| committer | Aurélien Bompard <aurelien@bompard.org> | 2012-10-26 12:38:52 +0200 |
| commit | cae57f7d5951e91f2f781f37e095acd88f999d89 (patch) | |
| tree | 11c61821222a38447773ead32fe151d7dde6ff06 | |
| parent | 3c98fc52c8238a5c2c6299b499ca5f413c533476 (diff) | |
| download | kittystore-cae57f7d5951e91f2f781f37e095acd88f999d89.tar.gz kittystore-cae57f7d5951e91f2f781f37e095acd88f999d89.tar.xz kittystore-cae57f7d5951e91f2f781f37e095acd88f999d89.zip | |
Pylint pass
| -rw-r--r-- | kittystore/import.py | 16 | ||||
| -rw-r--r-- | kittystore/scrub.py | 10 | ||||
| -rw-r--r-- | kittystore/storm/hack_datetime.py | 1 | ||||
| -rw-r--r-- | kittystore/storm/model.py | 2 | ||||
| -rw-r--r-- | kittystore/storm/store.py | 3 | ||||
| -rw-r--r-- | kittystore/test/test_storm_store.py | 8 | ||||
| -rw-r--r-- | kittystore/test/test_utils.py | 8 | ||||
| -rw-r--r-- | kittystore/utils.py | 3 |
8 files changed, 23 insertions, 28 deletions
diff --git a/kittystore/import.py b/kittystore/import.py index e63927a..5aead41 100644 --- a/kittystore/import.py +++ b/kittystore/import.py @@ -23,18 +23,12 @@ Import the content of a mbox file into the database. Author: Aurelien Bompard <abompard@fedoraproject.org> """ -import datetime import mailbox import os import re -import sys -import time import urllib -from base64 import b32encode from dateutil.parser import parse from dateutil import tz -from kitchen.text.converters import to_bytes -from hashlib import sha1 from optparse import OptionParser from random import randint from email.utils import unquote @@ -92,6 +86,8 @@ def convert_date(date_string): class DummyMailingList(object): + # pylint: disable=R0903 + # (Too few public methods) def __init__(self, address): self.fqdn_listname = unicode(address) self.display_name = None @@ -135,7 +131,7 @@ class DbImporter(object): str(randint(0, 100)))) print message["Message-Id"] try: - msg_id_hash = self.store.add_to_list(self.mlist, message) + self.store.add_to_list(self.mlist, message) except ValueError, e: if len(e.args) != 2: raise # Regular ValueError exception @@ -153,10 +149,10 @@ class DbImporter(object): def extract_attachments(self, message): """Parse message to search for attachments""" - has_attach = False message_text = message.as_string() - if "-------------- next part --------------" in message_text: - has_attach = True + #has_attach = False + #if "-------------- next part --------------" in message_text: + # has_attach = True # Regular attachments attachments = ATTACHMENT_RE.findall(message_text) for counter, att in enumerate(attachments): diff --git a/kittystore/scrub.py b/kittystore/scrub.py index 627668c..c3c9f52 100644 --- a/kittystore/scrub.py +++ b/kittystore/scrub.py @@ -24,12 +24,8 @@ from types import IntType from mimetypes import guess_all_extensions from email.utils import unquote -from email.charset import Charset -from mailman.utilities.string import websafe, oneline -# TODO: don't do translations here, the system locale has no meaning to the -# web user -from mailman.core.i18n import _ +from mailman.utilities.string import oneline # Path characters for common platforms pre = re.compile(r'[/\\:]') @@ -94,7 +90,7 @@ class Scrubber(object): def scrub(self): sanitize = 1 # TODO: implement other options - outer = True + #outer = True # Now walk over all subparts of this message and scrub out various types for part_num, part in enumerate(self.msg.walk()): ctype = part.get_content_type() @@ -164,7 +160,7 @@ class Scrubber(object): if payload is None: continue self.save_attachment(part, part_num) - outer = False + #outer = False # We still have to sanitize multipart messages to flat text because # Pipermail can't handle messages with list payloads. This is a kludge; # def (n) clever hack ;). diff --git a/kittystore/storm/hack_datetime.py b/kittystore/storm/hack_datetime.py index 6fe817b..0e87e71 100644 --- a/kittystore/storm/hack_datetime.py +++ b/kittystore/storm/hack_datetime.py @@ -3,6 +3,7 @@ # hack around a bug in storm: support for timezones is missing # https://bugs.launchpad.net/storm/+bug/280708 # +# pylint: disable=C,W,R import datetime import re diff --git a/kittystore/storm/model.py b/kittystore/storm/model.py index 7b231e1..e87a1fd 100644 --- a/kittystore/storm/model.py +++ b/kittystore/storm/model.py @@ -15,7 +15,7 @@ license. import datetime from zope.interface import implements -from storm.locals import * +from storm.locals import Unicode, RawStr, Int, ReferenceSet from mailman.interfaces.messages import IMessage from kittystore.utils import get_message_id_hash diff --git a/kittystore/storm/store.py b/kittystore/storm/store.py index ff29c83..b51e2c9 100644 --- a/kittystore/storm/store.py +++ b/kittystore/storm/store.py @@ -25,7 +25,7 @@ from kittystore.utils import get_ref_and_thread_id from zope.interface import implements from mailman.interfaces.messages import IMessageStore -from storm.locals import * +from storm.locals import Desc from storm.expr import And, Or from .model import List, Email, Attachment @@ -46,6 +46,7 @@ class StormStore(object): :param debug: a boolean to set the debug mode on or off. """ self.db = db + self.debug = debug # IMessageStore methods diff --git a/kittystore/test/test_storm_store.py b/kittystore/test/test_storm_store.py index b00d3ba..b96a3ce 100644 --- a/kittystore/test/test_storm_store.py +++ b/kittystore/test/test_storm_store.py @@ -1,18 +1,20 @@ # -*- coding: utf-8 -*- -# pylint: disable=R0904 +# pylint: disable=R0904,C0103 +# - Too many public methods +# - Invalid name XXX (should match YYY) import unittest import email -import mailbox import datetime from storm.exceptions import IntegrityError from kittystore.storm import get_storm_store from kittystore.storm.model import Email -from kittystore.test import get_test_file class FakeList(object): + # pylint: disable=R0903 + # (Too few public methods) def __init__(self, name): self.fqdn_listname = name diff --git a/kittystore/test/test_utils.py b/kittystore/test/test_utils.py index f52f999..d097789 100644 --- a/kittystore/test/test_utils.py +++ b/kittystore/test/test_utils.py @@ -20,8 +20,8 @@ class TestUtils(unittest.TestCase): msg = email.message_from_file(email_file, _class=Message) store = Mock() store.get_message_by_id_from_list.return_value = None - ref_id, thread_id = kittystore.utils.get_ref_and_thread_id( - msg, "example-list", store) + ref_id = kittystore.utils.get_ref_and_thread_id( + msg, "example-list", store)[0] self.assertEqual(ref_id, "200704070053.46646.other.person@example.com") def test_wrong_reply_to_format(self): @@ -29,8 +29,8 @@ class TestUtils(unittest.TestCase): msg = email.message_from_file(email_file, _class=Message) store = Mock() store.get_message_by_id_from_list.return_value = None - ref_id, thread_id = kittystore.utils.get_ref_and_thread_id( - msg, "example-list", store) + ref_id = kittystore.utils.get_ref_and_thread_id( + msg, "example-list", store)[0] self.assertEqual(ref_id, None) def test_non_ascii_headers(self): diff --git a/kittystore/utils.py b/kittystore/utils.py index 1cbe8db..913b229 100644 --- a/kittystore/utils.py +++ b/kittystore/utils.py @@ -24,10 +24,9 @@ Author: Aurelien Bompard <abompard@fedoraproject.org> """ import email.utils -import time import re from email.header import decode_header -from datetime import datetime, tzinfo, timedelta +from datetime import timedelta from base64 import b32encode from hashlib import sha1 # pylint: disable-msg=E0611 |
