Skip to content

Commit

Permalink
Support for locales, (en and it included)
Browse files Browse the repository at this point in the history
Based on PR #18, modified to no longer require pyyaml

This keeps email_reply_parser stdlib only, and allows easy addition
 of new locales without needing to parse config files
  • Loading branch information
kageurufu committed Sep 22, 2016
1 parent ae0923c commit 355b1b5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions email_reply_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from regexps import regexps
from locales import Locales

"""
email_reply_parser is a python library port of GitHub's Email Reply Parser.
Expand Down Expand Up @@ -42,7 +42,7 @@ def __init__(self, text, locale='en'):
self.fragment = None
self.text = text.replace('\r\n', '\n')
self.found_visible = False
self.regexps = regexps(locale)
self.regexps = Locales.get_locale(locale)

def read(self):
""" Creates new fragment for each line
Expand Down
19 changes: 19 additions & 0 deletions email_reply_parser/locales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Locales(object):
@classmethod
def get_locale(cls, locale='en'):
return getattr(cls, locale)

en = dict(
sig='(--|__|-\w)|(^Sent from my (\w+\s*){1,3})',
quote_hdr='^:etorw.*nO',
multi_quote_hdr='(?!On.*On\s.+?wrote:)(On\s(.+?)wrote:)',
quoted='(>+)',
header='^(From|Sent|To|Subject): .+',
)
it = dict(
sig='(--|__|-\w)|(^Inviato da (\w+\s*){1,3})',
quote_hdr='^:ottircs\sah.*lI',
multi_quote_hdr='(?!Il.*Il\s.+?ha\sscritto:)(Il\s(.+?)ha\sscritto:)',
quoted='(>+)',
header='^(Da|Data|A|Ogg): .+',
)
13 changes: 0 additions & 13 deletions email_reply_parser/locales.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions email_reply_parser/regexps.py

This file was deleted.

Empty file removed requirments.txt
Empty file.
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
],
requires=['pyyaml'],
tests_require=['pyyaml']
]
)

0 comments on commit 355b1b5

Please sign in to comment.