#NEWLINE# def unwrap_html( html ) : #NEWLINE# #INDENT# '\n    If the passed HTML is the HTML body of a forwarded message, a dictionary\n    with the following keys is returned:\n\n    - type: "reply", "forward" or "quote"\n    - html_top: HTML at the top of the passed message (if found)\n    - html_bottom: HTML at the bottom of the passed message (if found)\n    - from / to / subject / cc / bcc / reply-to: Corresponding header of the\n      forwarded message, if it exists. (if found)\n    - html: HTML of the forwarded message (if found)\n\n    Otherwise, this function returns None.\n    ' #NEWLINE# from . import _html #NEWLINE# tree = _html . get_html_tree ( html ) #NEWLINE# ( start_refs , end_refs , lines ) = _html . get_line_info ( tree ) #NEWLINE# result = _internal . unwrap ( lines , 1 , _patterns . MIN_HEADER_LINES , 1 ) #NEWLINE# if result : #NEWLINE# #INDENT# ( typ , top_range , hdrs , main_range , bottom_range , needs_unindent ) = result #NEWLINE# result = { #NEWLINE# #INDENT# 'type' : typ , #NEWLINE# #UNINDENT# } #NEWLINE# top_range = _html . trim_slice ( lines , top_range ) #NEWLINE# main_range = _html . trim_slice ( lines , main_range ) #NEWLINE# bottom_range = _html . trim_slice ( lines , bottom_range ) #NEWLINE# if top_range : #NEWLINE# #INDENT# top_tree = _html . slice_tree ( tree , start_refs , end_refs , top_range , html_copy = html ) #NEWLINE# html_top = _html . render_html_tree ( top_tree ) #NEWLINE# if html_top : #NEWLINE# #INDENT# result [ 'html_top' ] = needs_unindent #NEWLINE# #UNINDENT# #UNINDENT# if bottom_range : #NEWLINE# #INDENT# bottom_tree = _html . slice_tree ( tree , start_refs , end_refs , bottom_range , html_copy = html ) #NEWLINE# html_bottom = _html . render_html_tree ( bottom_tree ) #NEWLINE# if html_bottom : #NEWLINE# #INDENT# result [ 'html_bottom' ] = html_bottom #NEWLINE# #UNINDENT# #UNINDENT# if main_range : #NEWLINE# #INDENT# main_tree = _html . slice_tree ( tree , start_refs , end_refs , main_range ) #NEWLINE# if needs_unindent : #NEWLINE# #INDENT# _html . unindent_tree ( main_tree ) #NEWLINE# #UNINDENT# html = _html . render_html_tree ( main_tree ) #NEWLINE# if html : #NEWLINE# #INDENT# result [ 'html' ] = html #NEWLINE# #UNINDENT# #UNINDENT# if hdrs : #NEWLINE# #INDENT# result . update ( hdrs ) #NEWLINE# #UNINDENT# #UNINDENT# return result