diff options
| author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-11 16:43:31 -0700 |
|---|---|---|
| committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-12 12:32:57 -0700 |
| commit | b04b5d326175da6267817faca6239bf02a6e5931 (patch) | |
| tree | 63e997d31562cb75ec15fe38c5f422217fd490c3 /sqlparse | |
| parent | c4954af15bbcb93a61d111a218c2d9ba2aa7ea3a (diff) | |
| download | sqlparse-b04b5d326175da6267817faca6239bf02a6e5931.tar.gz | |
Refactor raw conversion on split_unquoted_newlines
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters/others.py | 4 | ||||
| -rw-r--r-- | sqlparse/utils.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/sqlparse/filters/others.py b/sqlparse/filters/others.py index 6951c74..71b1f8e 100644 --- a/sqlparse/filters/others.py +++ b/sqlparse/filters/others.py @@ -6,7 +6,6 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php from sqlparse import sql, tokens as T -from sqlparse.compat import text_type from sqlparse.utils import split_unquoted_newlines @@ -114,6 +113,5 @@ class SpacesAroundOperatorsFilter(object): class SerializerUnicode(object): @staticmethod def process(stmt): - raw = text_type(stmt) - lines = split_unquoted_newlines(raw) + lines = split_unquoted_newlines(stmt) return '\n'.join(line.rstrip() for line in lines) diff --git a/sqlparse/utils.py b/sqlparse/utils.py index 8253e0b..4a8646d 100644 --- a/sqlparse/utils.py +++ b/sqlparse/utils.py @@ -9,6 +9,7 @@ import itertools import re from collections import deque from contextlib import contextmanager +from sqlparse.compat import text_type # This regular expression replaces the home-cooked parser that was here before. # It is much faster, but requires an extra post-processing step to get the @@ -33,11 +34,12 @@ SPLIT_REGEX = re.compile(r""" LINE_MATCH = re.compile(r'(\r\n|\r|\n)') -def split_unquoted_newlines(text): +def split_unquoted_newlines(stmt): """Split a string on all unquoted newlines. Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite character is inside of a string.""" + text = text_type(stmt) lines = SPLIT_REGEX.split(text) outputlines = [''] for line in lines: |
