diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2015-10-26 20:14:18 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2015-10-26 20:14:18 +0100 |
| commit | 1992f6deff983f7a3332142da5c49e82544bd1ac (patch) | |
| tree | d76351e66f2502257bf81bdbefcf4fb6fa9c01fe /sqlparse/engine | |
| parent | f7e07b7b61be4befd5eaafce93aeb0238c884315 (diff) | |
| download | sqlparse-1992f6deff983f7a3332142da5c49e82544bd1ac.tar.gz | |
Cleanup module code.
Diffstat (limited to 'sqlparse/engine')
| -rw-r--r-- | sqlparse/engine/__init__.py | 4 | ||||
| -rw-r--r-- | sqlparse/engine/filter.py | 8 | ||||
| -rw-r--r-- | sqlparse/engine/grouping.py | 12 |
3 files changed, 13 insertions, 11 deletions
diff --git a/sqlparse/engine/__init__.py b/sqlparse/engine/__init__.py index 62c82b8..4d7fe88 100644 --- a/sqlparse/engine/__init__.py +++ b/sqlparse/engine/__init__.py @@ -43,8 +43,8 @@ class FilterStack(object): for filter_ in self.preprocess: stream = filter_.process(self, stream) - if (self.stmtprocess or self.postprocess or self.split_statements - or self._grouping): + if self.stmtprocess or self.postprocess or self.split_statements \ + or self._grouping: splitter = StatementFilter() stream = splitter.process(self, stream) diff --git a/sqlparse/engine/filter.py b/sqlparse/engine/filter.py index f7dd264..149db58 100644 --- a/sqlparse/engine/filter.py +++ b/sqlparse/engine/filter.py @@ -23,8 +23,8 @@ class StatementFilter: def _change_splitlevel(self, ttype, value): "Get the new split level (increase, decrease or remain equal)" # PostgreSQL - if (ttype == T.Name.Builtin - and value.startswith('$') and value.endswith('$')): + if ttype == T.Name.Builtin \ + and value.startswith('$') and value.endswith('$'): if self._in_dbldollar: self._in_dbldollar = False return -1 @@ -64,8 +64,8 @@ class StatementFilter: self._is_create = True return 0 - if (unified in ('IF', 'FOR') - and self._is_create and self._begin_depth > 0): + if unified in ('IF', 'FOR') \ + and self._is_create and self._begin_depth > 0: return 1 # Default diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index c8c2415..fe8b2e8 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -116,7 +116,7 @@ def group_as(tlist): def _right_valid(token): # Currently limited to DML/DDL. Maybe additional more non SQL reserved # keywords should appear here (see issue8). - return not token.ttype in (T.DML, T.DDL) + return token.ttype not in (T.DML, T.DDL) def _left_valid(token): if token.ttype is T.Keyword and token.value in ('NULL',): @@ -191,7 +191,8 @@ def group_identifier(tlist): i1 = tl.token_index(t1, start=i) if t1 else None t2_end = None if i1 is None else i1 + 1 - t2 = tl.token_next_by_instance(i, (sql.Function, sql.Parenthesis), end=t2_end) + t2 = tl.token_next_by_instance(i, (sql.Function, sql.Parenthesis), + end=t2_end) if t1 and t2: i2 = tl.token_index(t2, start=i) @@ -219,9 +220,10 @@ def group_identifier(tlist): if identifier_tokens and identifier_tokens[-1].ttype is T.Whitespace: identifier_tokens = identifier_tokens[:-1] if not (len(identifier_tokens) == 1 - and (isinstance(identifier_tokens[0], (sql.Function, sql.Parenthesis)) - or identifier_tokens[0].ttype in (T.Literal.Number.Integer, - T.Literal.Number.Float))): + and (isinstance(identifier_tokens[0], (sql.Function, + sql.Parenthesis)) + or identifier_tokens[0].ttype in ( + T.Literal.Number.Integer, T.Literal.Number.Float))): group = tlist.group_tokens(sql.Identifier, identifier_tokens) idx = tlist.token_index(group, start=idx) + 1 else: |
