(self, node)
return spaces
Calculates the formatted text for the space and comment tokens that
        prefix the node.

        Args:
          node: The Node with possible space and comment tokens in its range.

        Returns:
          A string representing the minified spaces.
Calculates the formatted text for the space and comment tokens that
        prefix the node.
Calculates the formatted text for the space and comment tokens that prefix the node .
def _get_code_for_spaces(self, node):
        """Calculates the formatted text for the space and comment tokens that
        prefix the node.

        Args:
          node: The Node with possible space and comment tokens in its range.

        Returns:
          A string representing the minified spaces.
        """
        start_pos = self._pos
        strs = []
        while (((node is None and self._pos < len(self._tokens)) or
                (node is not None and self._pos < node.end_pos)) and
               (isinstance(self._tokens[self._pos], lexer.TokSpace) or
                isinstance(self._tokens[self._pos], lexer.TokNewline) or
                isinstance(self._tokens[self._pos], lexer.TokComment))):
            strs.append(self._tokens[self._pos].code)
            self._pos += 1
        spaces = b''.join(strs)

        # Normalize space characters.
        spaces = re.sub(br'\t', b' ', spaces)
        spaces = re.sub(br'\r\n', b'\n', spaces)
        spaces = re.sub(br'\n\r', b'\n', spaces)
        spaces = re.sub(br'\r', b'\n', spaces)

        # Delete trailing whitespace.
        spaces = re.sub(br' +\n', b'\n', spaces)

        # If a comment is on the same line as previous, separate it by two
        # spaces.
        if start_pos != 0:
            spaces = re.sub(br'^ *--', b'  --', spaces)

        # If a comment is on its own line, indent it at the indent level.
        spaces = re.sub(
            br'\n *--',
            b'\n' + b' ' * self._indent_mult * self._indent + b'--',
            spaces)
        if start_pos == 0:
            spaces = re.sub(br'^ *--', b'--', spaces)

        # If next non-space is on its own line, indent it at the indent level.
        spaces = re.sub(
            br'\n *$', b'\n' + b' ' * self._indent_mult * self._indent,
            spaces)
        if start_pos == 0:
            spaces = re.sub(br'^ *$', b'', spaces)

        # Collapse regions of 2+ consecutive newlines to 2 newlines.
        # TODO: two blank lines before function defs? classes?
        spaces = re.sub(br'\n\n+', b'\n\n', spaces)

        # Remove excess trailing whitespace at end of file.
        if self._pos == len(self._tokens):
            spaces = re.sub(br'[ \n]+$', b'\n', spaces)

        # TODO: same-line spacing patterns:
        # - one space before and after binop
        # - one space before unop, no space after (except "not")
        # - no space inside parens or braces
        # - no space to left of comma or semicolon; one space after
        # - no space around colons (for methods)
        # - no "empty" semicolon statements; non-empty semicolon should be
        #    adjacent to its statement
        # - block starts on a new line; 'end' always on its own line

        return spaces
def _get_code_for_spaces ( self , node ) : start_pos = self . _pos strs = [ ] while ( ( ( node is None and self . _pos < len ( self . _tokens ) ) or ( node is not None and self . _pos < node . end_pos ) ) and ( isinstance ( self . _tokens [ self . _pos ] , lexer . TokSpace ) or isinstance ( self . _tokens [ self . _pos ] , lexer . TokNewline ) or isinstance ( self . _tokens [ self . _pos ] , lexer . TokComment ) ) ) : strs . append ( self . _tokens [ self . _pos ] . code ) self . _pos += 1 spaces = b'' . join ( strs ) # Normalize space characters. spaces = re . sub ( br'\t' , b' ' , spaces ) spaces = re . sub ( br'\r\n' , b'\n' , spaces ) spaces = re . sub ( br'\n\r' , b'\n' , spaces ) spaces = re . sub ( br'\r' , b'\n' , spaces ) # Delete trailing whitespace. spaces = re . sub ( br' +\n' , b'\n' , spaces ) # If a comment is on the same line as previous, separate it by two # spaces. if start_pos != 0 : spaces = re . sub ( br'^ *--' , b'  --' , spaces ) # If a comment is on its own line, indent it at the indent level. spaces = re . sub ( br'\n *--' , b'\n' + b' ' * self . _indent_mult * self . _indent + b'--' , spaces ) if start_pos == 0 : spaces = re . sub ( br'^ *--' , b'--' , spaces ) # If next non-space is on its own line, indent it at the indent level. spaces = re . sub ( br'\n *$' , b'\n' + b' ' * self . _indent_mult * self . _indent , spaces ) if start_pos == 0 : spaces = re . sub ( br'^ *$' , b'' , spaces ) # Collapse regions of 2+ consecutive newlines to 2 newlines. # TODO: two blank lines before function defs? classes? spaces = re . sub ( br'\n\n+' , b'\n\n' , spaces ) # Remove excess trailing whitespace at end of file. if self . _pos == len ( self . _tokens ) : spaces = re . sub ( br'[ \n]+$' , b'\n' , spaces ) # TODO: same-line spacing patterns: # - one space before and after binop # - one space before unop, no space after (except "not") # - no space inside parens or braces # - no space to left of comma or semicolon; one space after # - no space around colons (for methods) # - no "empty" semicolon statements; non-empty semicolon should be #    adjacent to its statement # - block starts on a new line; 'end' always on its own line return spaces