diff options
| author | Jesús Leganés Combarro "Piranna" <jesus.lc@vaelsys.com> | 2012-05-18 12:20:35 +0200 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <jesus.lc@vaelsys.com> | 2012-05-18 12:20:35 +0200 |
| commit | 02999ed9af5dac5e1131b1e61332bcab6a686c4a (patch) | |
| tree | 7ba62d6a5e8ad46c78bafd4739eb90750742c2a4 /sqlparse | |
| parent | de495d42d3be77e7ca70dd7dab4488a3a719f4c2 (diff) | |
| download | sqlparse-02999ed9af5dac5e1131b1e61332bcab6a686c4a.tar.gz | |
Clean-up of process
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 2c1f0eb..f69cea8 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -405,25 +405,33 @@ class ReindentFilter: self._split_statements(tlist) if kwds: self._split_kwds(tlist) - [self._process(sgroup) for sgroup in tlist.get_sublists()] + + for sgroup in tlist.get_sublists(): + self._process(sgroup) def process(self, stack, stmt): warn("Deprecated, use callable objects. This will be removed at 0.2.0", DeprecationWarning) + # If we are processing a statement, set it as the current one if isinstance(stmt, sql.Statement): self._curr_stmt = stmt + + # Process the statement self._process(stmt) + + # If we are processing a statement, check if we should add a new line if isinstance(stmt, sql.Statement): - if self._last_stmt is not None: + if self._last_stmt != None: if unicode(self._last_stmt).endswith('\n'): nl = '\n' else: nl = '\n\n' - stmt.tokens.insert(0, - sql.Token(T.Whitespace, nl)) - if self._last_stmt != stmt: - self._last_stmt = stmt + + stmt.tokens.insert(0, sql.Token(T.Whitespace, nl)) + + # Set the statement as the current one + self._last_stmt = stmt # FIXME: Doesn't work ;) |
