diff options
| author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-05-10 21:39:54 -0700 |
|---|---|---|
| committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-05-10 21:39:54 -0700 |
| commit | e4bf805cad1a41b989b59ac58f526c6bc9b0e338 (patch) | |
| tree | c2c0bbc457f5f6143f1e9f897afac05a15d1fde8 /sqlparse | |
| parent | 015bf8393286301ca0d4dfd087b4ed305fa71d4a (diff) | |
| download | sqlparse-e4bf805cad1a41b989b59ac58f526c6bc9b0e338.tar.gz | |
refactor remove quotes
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/sql.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 777d582..673e452 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -7,7 +7,7 @@ import sys from sqlparse import tokens as T from sqlparse.compat import string_types, u -from sqlparse.utils import imt +from sqlparse.utils import imt, remove_quotes class Token(object): @@ -185,14 +185,6 @@ class TokenList(Token): if (token.is_group() and (max_depth is None or depth < max_depth)): token._pprint_tree(max_depth, depth + 1) - def _remove_quotes(self, val): - """Helper that removes surrounding quotes from strings.""" - if not val: - return val - if val[0] in ('"', '\'') and val[-1] == val[0]: - val = val[1:-1] - return val - def get_token_at_offset(self, offset): """Returns the token that is on position offset.""" idx = 0 @@ -482,7 +474,7 @@ class TokenList(Token): prev_ = self.token_prev(self.token_index(dot)) if prev_ is None: # something must be verry wrong here.. return None - return self._remove_quotes(prev_.value) + return remove_quotes(prev_.value) def _get_first_name(self, idx=None, reverse=False, keywords=False): """Returns the name of the first token with a name""" @@ -499,7 +491,7 @@ class TokenList(Token): for tok in tokens: if tok.ttype in types: - return self._remove_quotes(tok.value) + return remove_quotes(tok.value) elif isinstance(tok, Identifier) or isinstance(tok, Function): return tok.get_name() return None |
