Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = crlf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.{py,ini,yaml,yml,rst}]
indent_style = space
indent_size = 4
continuation_indent_size = 4
trim_trailing_whitespace = true

[{Makefile,*.bat}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# PyCharm
.idea/

*.pyc
docs/build
dist
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Alphabetical list of contributors:
* spigwitmer <itgpmc@gmail.com>
* Tim Graham <timograham@gmail.com>
* Victor Hahn <info@victor-hahn.de>
* Victor Uriarte <vmuriart@gmail.com>
* vthriller <farreva232@yandex.ru>
* wayne.wuw <wayne.wuw@alibaba-inc.com>
* Yago Riveiro <yago.riveiro@gmail.com>
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/column_defs_lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
parsed = sqlparse.parse(SQL)[0]

# extract the parenthesis which holds column definitions
par = parsed.token_next_by_instance(0, sqlparse.sql.Parenthesis)
par = parsed.token_next_by(i=sqlparse.sql.Parenthesis)


def extract_definitions(token_list):
Expand Down
23 changes: 17 additions & 6 deletions sqlparse/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,40 @@
PY3 = sys.version_info[0] == 3

if PY3:
def u(s):
return str(s)


range = range
text_type = str
string_types = (str,)
from io import StringIO

def u(s):
return str(s)

elif PY2:
def u(s, encoding=None):
encoding = encoding or 'unicode-escape'
try:
return unicode(s)
except UnicodeDecodeError:
return unicode(s, encoding)


range = xrange
text_type = unicode
string_types = (basestring,)
from StringIO import StringIO # flake8: noqa

def u(s):
return unicode(s)
from StringIO import StringIO


# Directly copied from six:
def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""

# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(meta):
def __new__(cls, name, this_bases, d):
return meta(name, bases, d)

return type.__new__(metaclass, 'temporary_class', (), {})
Loading