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

        Args:
          node: The Node with possible space and comment tokens in its range,
            or None to just get spaces from the current token position.

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

        Args:
          node: The Node with possible space and comment tokens in its range,
            or None to just get spaces from the current token position.

        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))):
            if not isinstance(self._tokens[self._pos], lexer.TokComment):
                strs.append(self._tokens[self._pos].code)
            self._pos += 1

        if (start_pos == 0) or (self._pos == len(self._tokens)):
            # Eliminate all spaces at beginning and end of code.
            return b''

        spaces = b''.join(strs)
        spaces = re.sub(br'\t', b' ', spaces)      # one tab -> one space
        spaces = re.sub(br'\n +', b'\n', spaces)   # leading spaces -> none
        spaces = re.sub(br' +\n', b'\n', spaces)   # trailing spaces -> none
        # multiple spaces -> one space
        spaces = re.sub(br'  +', b' ', spaces)
        # multiple newlines -> one newline
        spaces = re.sub(br'\n\n+', b'\n', spaces)

        # TODO: Eliminate space between symbols and names/keywords on the same
        # line. (Use self._tokens[start_pos-1] and self._tokens[self._pos].)

        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 ) ) ) : if not isinstance ( self . _tokens [ self . _pos ] , lexer . TokComment ) : strs . append ( self . _tokens [ self . _pos ] . code ) self . _pos += 1 if ( start_pos == 0 ) or ( self . _pos == len ( self . _tokens ) ) : # Eliminate all spaces at beginning and end of code. return b'' spaces = b'' . join ( strs ) spaces = re . sub ( br'\t' , b' ' , spaces ) # one tab -> one space spaces = re . sub ( br'\n +' , b'\n' , spaces ) # leading spaces -> none spaces = re . sub ( br' +\n' , b'\n' , spaces ) # trailing spaces -> none # multiple spaces -> one space spaces = re . sub ( br'  +' , b' ' , spaces ) # multiple newlines -> one newline spaces = re . sub ( br'\n\n+' , b'\n' , spaces ) # TODO: Eliminate space between symbols and names/keywords on the same # line. (Use self._tokens[start_pos-1] and self._tokens[self._pos].) return spaces