diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-02-03 14:32:06 +0100 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-02-03 14:32:06 +0100 |
| commit | eec7cd398cf404de874980518ccf46b0f7db00e8 (patch) | |
| tree | dd71e464766dfc2e52b97913f586176ed8a9636e /sqlparse | |
| parent | a911e95665b303a898d6e2de44a1327c0c271c8f (diff) | |
| download | sqlparse-eec7cd398cf404de874980518ccf46b0f7db00e8.tar.gz | |
Change all internal use of to_unicode() to __unicode__() and marked former one as deprecated.
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 8 | ||||
| -rw-r--r-- | sqlparse/sql.py | 11 |
2 files changed, 11 insertions, 8 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 6f9b579..9aa3f6d 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -350,7 +350,7 @@ class ReindentFilter(Filter): self._process(stmt) if isinstance(stmt, sql.Statement): if self._last_stmt is not None: - if self._last_stmt.to_unicode().endswith('\n'): + if unicode(self._last_stmt).endswith('\n'): nl = '\n' else: nl = '\n\n' @@ -382,7 +382,7 @@ class RightMarginFilter(Filter): and not token.__class__ in self.keep_together): token.tokens = self._process(stack, token, token.tokens) else: - val = token.to_unicode() + val = unicode(token) if len(self.line) + len(val) > self.width: match = re.search('^ +', self.line) if match is not None: @@ -456,7 +456,7 @@ class ColumnsSelect(Filter): class SerializerUnicode(Filter): def process(self, stack, stmt): - raw = stmt.to_unicode() + raw = unicode(stmt) add_nl = raw.endswith('\n') res = '\n'.join(line.rstrip() for line in raw.splitlines()) if add_nl: @@ -516,7 +516,7 @@ class OutputPythonFilter(Filter): varname = '%s%d' % (self.varname, self.cnt) else: varname = self.varname - has_nl = len(stmt.to_unicode().strip().splitlines()) > 1 + has_nl = len(unicode(stmt).strip().splitlines()) > 1 stmt.tokens = self._process(stmt.tokens, varname, self.cnt, has_nl) return stmt diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 244733b..d077c1d 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -31,10 +31,14 @@ class Token(object): short, id(self)) def __unicode__(self): + """Returns a unicode representation of this object.""" return self.value or '' def to_unicode(self): - """Returns a unicode representation of this object.""" + """Returns a unicode representation of this object. + + @deprecated: please use __unicode__() + """ return unicode(self) def _get_repr_name(self): @@ -333,8 +337,7 @@ class TokenList(Token): alias = next_ if isinstance(alias, Identifier): return alias.get_name() - else: - return alias.to_unicode() + return unicode(alias) def get_name(self): """Returns the name of this identifier. @@ -420,7 +423,7 @@ class Identifier(TokenList): next_ = self.token_next(self.token_index(marker), False) if next_ is None: return None - return next_.to_unicode() + return unicode(next_) class IdentifierList(TokenList): |
