diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-03-21 18:38:39 +0100 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-03-21 18:38:39 +0100 |
| commit | 0691a8c8a38485745098b21cf46f8dac655a0b98 (patch) | |
| tree | da42cfcd9738952a24f035c4bdfd06d022ac2039 /sqlparse | |
| parent | 5e22117999d7ca9ecc82326bd585841d04dd1036 (diff) | |
| download | sqlparse-0691a8c8a38485745098b21cf46f8dac655a0b98.tar.gz | |
Clean-up and comments of StripWhitespace
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index d54105e..a639f7a 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -76,23 +76,30 @@ class StripComments(Filter): def StripWhitespace(stream): - """Strip the whitespaces from a stream""" + """Strip the whitespaces from a stream leaving only one between tokens""" last_type = None for token_type, value in stream: - if last_type == None: - if token_type not in Whitespace + Punctuation: - yield token_type, value - last_type = token_type + print repr(token_type), repr(value) + # We got a previous token + if last_type: + print '\t 1', repr(token_type), repr(value) - else: if token_type in Whitespace: - if last_type not in Whitespace: - yield token_type, ' ' - else: - yield token_type, value + if last_type in Whitespace: + continue + value = ' ' + + # Ignore first empty spaces and dot-commas + elif token_type in Whitespace + Punctuation: + continue + + # There's no previous token + else: + print '\t 2', repr(token_type), repr(value) - last_type = token_type + yield token_type, value + last_type = token_type class IncludeStatement(Filter): |
