def reduce_operators(source):
io_obj = io.StringIO(source)<EOL>prev_tok = None<EOL>out_tokens = []<EOL>out = "<STR_LIT>"<EOL>last_lineno = -<NUM_LIT:1><EOL>last_col = <NUM_LIT:0><EOL>nl_types = (tokenize.NL, tokenize.NEWLINE)<EOL>joining_strings = False<EOL>new_string = "<STR_LIT>"<EOL>for tok in tokenize.generate_tokens(io_obj.readline):<EOL><INDENT>token_type = tok[<NUM_LIT:0>]<EOL>token_string = tok[<NUM_LIT:1>]<EOL>start_line, start_col = tok[<NUM_LIT:2>]<EOL>end_line, end_col = tok[<NUM_LIT:3>]<EOL>if start_line > last_lineno:<EOL><INDENT>last_col = <NUM_LIT:0><EOL><DEDENT>if token_type != tokenize.OP:<EOL><INDENT>if start_col > last_col and token_type not in nl_types:<EOL><INDENT>if prev_tok[<NUM_LIT:0>] != tokenize.OP:<EOL><INDENT>out += ("<STR_LIT:U+0020>" * (start_col - last_col))<EOL><DEDENT><DEDENT>if token_type == tokenize.STRING:<EOL><INDENT>if prev_tok[<NUM_LIT:0>] == tokenize.STRING:<EOL><INDENT>string_type = token_string[<NUM_LIT:0>] <EOL>prev_string_type = prev_tok[<NUM_LIT:1>][<NUM_LIT:0>]<EOL>out = out.rstrip("<STR_LIT:U+0020>") <EOL>if not joining_strings:<EOL><INDENT>out = out[:(len(out)-len(prev_tok[<NUM_LIT:1>]))]<EOL>prev_string = prev_tok[<NUM_LIT:1>].strip(prev_string_type)<EOL>new_string = (<EOL>prev_string + token_string.strip(string_type))<EOL>joining_strings = True<EOL><DEDENT>else:<EOL><INDENT>new_string += token_string.strip(string_type)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if token_string in ('<STR_LIT:}>', '<STR_LIT:)>', '<STR_LIT:]>'):<EOL><INDENT>if prev_tok[<NUM_LIT:1>] == '<STR_LIT:U+002C>':<EOL><INDENT>out = out.rstrip('<STR_LIT:U+002C>')<EOL><DEDENT><DEDENT>if joining_strings:<EOL><INDENT>out += "<STR_LIT>" + new_string + "<STR_LIT>"<EOL>joining_strings = False<EOL><DEDENT>if token_string == '<STR_LIT:@>': <EOL><INDENT>if prev_tok[<NUM_LIT:0>] == tokenize.NEWLINE:<EOL><INDENT>out += ("<STR_LIT:U+0020>" * (start_col - last_col))<EOL><DEDENT><DEDENT><DEDENT>if not joining_strings:<EOL><INDENT>out += token_string<EOL><DEDENT>last_col = end_col<EOL>last_lineno = end_line<EOL>prev_tok = tok<EOL><DEDENT>return out<EOL>
Remove spaces between operators in *source* and returns the result.
Example::

    def foo(foo, bar, blah):
        test = "This is a %s" % foo

Will become::

    def foo(foo,bar,blah):
        test="This is a %s"%foo

..  note::

    Also removes trailing commas and joins disjointed strings like
    ``("foo" "bar")``.