diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-05-15 16:10:45 +0200 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-05-15 16:10:45 +0200 |
| commit | ac973f8832f191ff996d5df005dadbf4d6ef2bb7 (patch) | |
| tree | 32b87d1c0cf7448f6cc988e756614e460d7f37a5 /sqlparse | |
| parent | ec6c9cd4dfd7dd428d8d33027f3ded02f80957a6 (diff) | |
| download | sqlparse-ac973f8832f191ff996d5df005dadbf4d6ef2bb7.tar.gz | |
Changed StripCommentsFilter, StripWhitespaceFilter & RightMarginFilter
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/engine/__init__.py | 2 | ||||
| -rw-r--r-- | sqlparse/filters.py | 25 |
2 files changed, 8 insertions, 19 deletions
diff --git a/sqlparse/engine/__init__.py b/sqlparse/engine/__init__.py index 581b4e8..552360a 100644 --- a/sqlparse/engine/__init__.py +++ b/sqlparse/engine/__init__.py @@ -62,7 +62,7 @@ class FilterStack(object): ret = [] for stmt in stream: for filter_ in self.stmtprocess: - filter_.process(self, stmt) + filter_(stmt) ret.append(stmt) return ret stream = _run1(stream) diff --git a/sqlparse/filters.py b/sqlparse/filters.py index b11b7aa..56c9a36 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -153,7 +153,6 @@ class IncludeStatement: # statement process class StripCommentsFilter: - def _get_next_comment(self, tlist): # TODO(andi) Comment types should be unified, see related issue38 token = tlist.token_next_by_instance(0, sql.Comment) @@ -178,16 +177,13 @@ class StripCommentsFilter: tlist.tokens.pop(tidx) token = self._get_next_comment(tlist) - def process(self, stack, stmt): - warn("Deprecated, use callable objects. This will be removed at 0.2.0", - DeprecationWarning) - - [self.process(stack, sgroup) for sgroup in stmt.get_sublists()] + def __call__(self, stmt): + for sgroup in stmt.get_sublists(): + self(sgroup) self._process(stmt) class StripWhitespaceFilter: - def _stripws(self, tlist): func_name = '_stripws_%s' % tlist.__class__.__name__.lower() func = getattr(self, func_name, self._stripws_default) @@ -210,19 +206,15 @@ class StripWhitespaceFilter: tlist.tokens.pop(-2) self._stripws_default(tlist) - def process(self, stack, stmt, depth=0): - warn("Deprecated, use callable objects. This will be removed at 0.2.0", - DeprecationWarning) - - [self.process(stack, sgroup, depth + 1) - for sgroup in stmt.get_sublists()] + def __call__(self, stmt, depth=0): + for sgroup in stmt.get_sublists(): + self(sgroup, depth + 1) self._stripws(stmt) if depth == 0 and stmt.tokens[-1].is_whitespace(): stmt.tokens.pop(-1) class ReindentFilter: - def __init__(self, width=2, char=' ', line_width=None): self.width = width self.char = char @@ -369,10 +361,7 @@ class ReindentFilter: self._split_kwds(tlist) [self._process(sgroup) for sgroup in tlist.get_sublists()] - def process(self, stack, stmt): - warn("Deprecated, use callable objects. This will be removed at 0.2.0", - DeprecationWarning) - + def __call__(self, stmt): if isinstance(stmt, sql.Statement): self._curr_stmt = stmt self._process(stmt) |
