# Path: talon/utils.py
# def get_delimiter(msg_body):
#     delimiter = RE_DELIMITER.search(msg_body)
#     if delimiter:
#         delimiter = delimiter.group()
#     else:
#         delimiter = '\n'
# 
#     return delimiter
# 
# def html_tree_to_text(tree):
#     for style in CSSSelector('style')(tree):
#         style.getparent().remove(style)
# 
#     for c in tree.xpath('//comment()'):
#         parent = c.getparent()
# 
#         # comment with no parent does not impact produced text
#         if parent is None:
#             continue
# 
#         parent.remove(c)
# 
#     text = ""
#     for el in tree.iter():
#         el_text = (el.text or '') + (el.tail or '')
#         if len(el_text) > 1:
#             if el.tag in _BLOCKTAGS + _HARDBREAKS:
#                 text += "\n"
#             if el.tag == 'li':
#                 text += "  * "
#             text += el_text.strip() + " "
# 
#             # add href to the output
#             href = el.attrib.get('href')
#             if href:
#                 text += "(%s) " % href
# 
#         if (el.tag in _HARDBREAKS and text and
#             not text.endswith("\n") and not el_text):
#             text += "\n"
# 
#     retval = _rm_excessive_newlines(text)
#     return _encode_utf8(retval)
# 
# def html_document_fromstring(s):
#     """Parse html tree from string. Return None if the string can't be parsed.
#     """
#     if isinstance(s, six.text_type):
#         s = s.encode('utf8')
#     try:
#         return html5parser.document_fromstring(s, parser=_html5lib_parser())
#     except Exception:
#         pass
# 
# Path: talon/html_quotations.py
# CHECKPOINT_PREFIX = '#!%!'
# CHECKPOINT_SUFFIX = '!%!#'
# CHECKPOINT_PATTERN = re.compile(CHECKPOINT_PREFIX + '\d+' + CHECKPOINT_SUFFIX)
# QUOTE_IDS = ['OLK_SRC_BODY_SECTION']
# RE_FWD = re.compile("^[-]+[ ]*Forwarded message[ ]*[-]+$", re.I | re.M)
# def add_checkpoint(html_note, counter):
# def delete_quotation_tags(html_note, counter, quotation_checkpoints):
# def cut_gmail_quote(html_message):
# def cut_microsoft_quote(html_message):
# def cut_by_id(html_message):
# def cut_blockquote(html_message):
# def cut_from_block(html_message):
# def cut_zimbra_quote(html_message):


import regex as re
import logging
import six
from copy import deepcopy
from lxml import html, etree
from talon.utils import (get_delimiter, html_tree_to_text,
                         html_document_fromstring)
from talon import html_quotations
from six.moves import range
        u'|'.join((
        	'Op',
        	#German
        	'Am'
        )),
        # Ending of the line
        u'|'.join((
            # Dutch
            'schreef','verzond','geschreven',
            # German
            'schrieb'
        ))
    )
    )

RE_QUOTATION = re.compile(
    r'''
    (
        # quotation border: splitter line or a number of quotation marker lines
        (?:
            s
            |
            (?:me*){2,}
        )

        # quotation lines could be marked as splitter or text, etc.
        .*

        # but we expect it to end with a quotation marker line
        me*

# Path: talon/utils.py
# def get_delimiter(msg_body):
#     delimiter = RE_DELIMITER.search(msg_body)
#     if delimiter:
#         delimiter = delimiter.group()
#     else:
#         delimiter = '\n'
# 
#     return delimiter
# 
# def html_tree_to_text(tree):
#     for style in CSSSelector('style')(tree):
#         style.getparent().remove(style)
# 
#     for c in tree.xpath('//comment()'):
#         parent = c.getparent()
# 
#         # comment with no parent does not impact produced text
#         if parent is None:
#             continue
# 
#         parent.remove(c)
# 
#     text = ""
#     for el in tree.iter():
#         el_text = (el.text or '') + (el.tail or '')
#         if len(el_text) > 1:
#             if el.tag in _BLOCKTAGS + _HARDBREAKS:
#                 text += "\n"
#             if el.tag == 'li':
#                 text += "  * "
#             text += el_text.strip() + " "
# 
#             # add href to the output
#             href = el.attrib.get('href')
#             if href:
#                 text += "(%s) " % href
# 
#         if (el.tag in _HARDBREAKS and text and
#             not text.endswith("\n") and not el_text):
#             text += "\n"
# 
#     retval = _rm_excessive_newlines(text)
#     return _encode_utf8(retval)
# 
# def html_document_fromstring(s):
#     """Parse html tree from string. Return None if the string can't be parsed.
#     """
#     if isinstance(s, six.text_type):
#         s = s.encode('utf8')
#     try:
#         return html5parser.document_fromstring(s, parser=_html5lib_parser())
#     except Exception:
#         pass
# 
# Path: talon/html_quotations.py
# CHECKPOINT_PREFIX = '#!%!'
# CHECKPOINT_SUFFIX = '!%!#'
# CHECKPOINT_PATTERN = re.compile(CHECKPOINT_PREFIX + '\d+' + CHECKPOINT_SUFFIX)
# QUOTE_IDS = ['OLK_SRC_BODY_SECTION']
# RE_FWD = re.compile("^[-]+[ ]*Forwarded message[ ]*[-]+$", re.I | re.M)
# def add_checkpoint(html_note, counter):
# def delete_quotation_tags(html_note, counter, quotation_checkpoints):
# def cut_gmail_quote(html_message):
# def cut_microsoft_quote(html_message):
# def cut_by_id(html_message):
# def cut_blockquote(html_message):
# def cut_from_block(html_message):
# def cut_zimbra_quote(html_message):


# Path: talon/quotations.py
import regex as re
import logging
import six
from copy import deepcopy
from lxml import html, etree
from talon.utils import (get_delimiter, html_tree_to_text,
                         html_document_fromstring)
from talon import html_quotations
from six.moves import range

        u'|'.join((
        	'Op',
        	#German
        	'Am'
        )),
        # Ending of the line
        u'|'.join((
            # Dutch
            'schreef','verzond','geschreven',
            # German
            'schrieb'
        ))
    )
    )

RE_QUOTATION = re.compile(
    r'''
    (
        # quotation border: splitter line or a number of quotation marker lines
        (?:
            s
            |
            (?:me*){2,}
        )

        # quotation lines could be marked as splitter or text, etc.
        .*

        # but we expect it to end with a quotation marker line
        me*

    )