Skip to content

Commit

Permalink
Added Swedish Gmail patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersTornkvist authored and thomasst committed Jun 7, 2018
1 parent 4e60942 commit ea53058
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion quotequail/_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
u'^Le (.*) a écrit :$', # French
u'El (.*) escribió:$', # Spanish
u'^(.*) написал\(а\):$', # Russian
u'^Den (.*) skrev (.*):$', # Swedish
u'([0-9]{4}/[0-9]{1,2}/[0-9]{1,2}) (.* <.*@.*>)$', # gmail (?) reply
]

Expand All @@ -19,7 +20,7 @@
u'Début du message réexpédié', 'Inicio del mensaje reenviado',

# gmail/evolution forward
'Forwarded [mM]essage', 'Mensaje reenviado',
'Forwarded [mM]essage', 'Mensaje reenviado', 'Vidarebefordrat meddelande',

# outlook
'Original [mM]essage', 'Ursprüngliche Nachricht', 'Mensaje [oO]riginal',
Expand Down Expand Up @@ -53,16 +54,19 @@
'von': 'from',
'de': 'from',
u'от кого': 'from',
u'från': 'from',

'to': 'to',
'an': 'to',
'para': 'to',
u'à': 'to',
u'pour': 'to',
u'кому': 'to',
u'till': 'to',

'cc': 'cc',
'kopie': 'cc',
'kopia': 'cc',

'bcc': 'bcc',
'cco': 'bcc',
Expand All @@ -89,6 +93,7 @@
'objet': 'subject',
'sujet': 'subject',
u'тема': 'subject',
u'ämne': 'subject',
}

COMPILED_PATTERN_MAP = {
Expand Down
30 changes: 30 additions & 0 deletions tests/test_quotequail.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,28 @@ def test_forward_french_thunderbird(self):
'type': 'forward'
})

def test_gmail_forward_swedish(self):
# Gmail forward
self.assertEqual(unwrap(u"""Hello
---------- Vidarebefordrat meddelande ----------
Från: Someone <[email protected]>
Datum: 26 april 2013 20:13
Ämne: Weekend Spanish classes
Till: [email protected]
Spanish Classes
Learn Spanish
"""), {
'text_top': u'Hello',
'type': u'forward',
'from': u'Someone <[email protected]>',
'date': u'26 april 2013 20:13',
'subject': u'Weekend Spanish classes',
'to': u'[email protected]',
'text': u'Spanish Classes\nLearn Spanish',
})

class HTMLUnwrapTestCase(FileMixin, unittest.TestCase):
def test_simple_forward(self):
html = u'Begin forwarded message:<br>\n<br>\nFrom: [email protected]<br>\nTo: [email protected]<br>\nSubject: You won<br>\n'
Expand Down Expand Up @@ -816,6 +838,14 @@ def test_parse_reply(self):
'from': u'John Doe'
})

# Swedish
data = parse_reply(u'Den 24 februari 2015 22:48 skrev John Doe <[email protected]>:')
self.assertEqual(data, {
'date': u'24 februari 2015 22:48',
'from': u'John Doe <[email protected]>'
})


class InternalHTMLTestCase(unittest.TestCase):
def test_extract_headers(self):
from quotequail._internal import extract_headers
Expand Down

0 comments on commit ea53058

Please sign in to comment.