@staticmethod
def _reattach_blank(lines, signal_boundaries=False):
    """
        Reattach blank lines to the preceding non-blank line.

        Initial blank lines are prepended to the first non-
        blank line.

        If signal_boundaries is True, the position of the blank
        lines is signaled through yielding None.
        This boundary is always signaled at the beginning, even
        if there are no leading blank lines.
        """
    last = ''
    for line in lines:
        last += line
        if line.strip():
            break
    if signal_boundaries and last:
        yield None
    boundary = False
    for line in lines:
        if not line.strip():
            boundary = True
            last += line
        else:
            yield last
            last = line
            if signal_boundaries and boundary:
                yield None
                boundary = False
    if last:
        yield last
