def translate_logical_line(start, end, contents, indent_stack, endmarker=False):
    """Translate raw contents to logical lines"""
    # Remove leading blank lines.
    while contents[0] == '\n':
      start += 1
      contents.pop(0)
    # Remove trailing blank lines.
    while contents[-1] == '\n':
      end -= 1
      contents.pop()

    indent = len(indent_stack[-1]) if indent_stack else 0
    if endmarker:
      indent = len(contents[0])
    return start, end + 1, indent
def translate_logical_line ( start , end , contents , indent_stack , endmarker = False ) : while contents [ 0 ] == '\n' : start += 1 contents . pop ( 0 ) while contents [ - 1 ] == '\n' : end -= 1 contents . pop ( ) indent = len ( indent_stack [ - 1 ] ) if indent_stack else 0 if endmarker : indent = len ( contents [ 0 ] ) return start , end + 1 , indent
Translate raw contents to logical lines