summaryrefslogtreecommitdiff
path: root/sqlparse/formatter.py
diff options
context:
space:
mode:
authorAdam Greenhall <agreenhall@lyft.com>2015-09-11 16:51:06 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-06 06:31:35 -0700
commita9427d9aff77fd6fcd8ab8d13fc2a87eb16cc2b9 (patch)
treeabe7af31276061bd8da27bc077a3a1950a516f6b /sqlparse/formatter.py
parentb9d81ac4fe49114f57dc33c0d635f99ff56e62f2 (diff)
downloadsqlparse-a9427d9aff77fd6fcd8ab8d13fc2a87eb16cc2b9.tar.gz
Start work on Aligned-reindent
Diffstat (limited to 'sqlparse/formatter.py')
-rw-r--r--sqlparse/formatter.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py
index 7441313..5af8743 100644
--- a/sqlparse/formatter.py
+++ b/sqlparse/formatter.py
@@ -55,6 +55,13 @@ def validate_options(options):
elif reindent:
options['strip_whitespace'] = True
+ reindent_aligned = options.get('reindent_aligned', False)
+ if reindent_aligned not in [True, False]:
+ raise SQLParseError('Invalid value for reindent_aligned: %r'
+ % reindent)
+ elif reindent_aligned:
+ options['strip_whitespace'] = True
+
indent_tabs = options.get('indent_tabs', False)
if indent_tabs not in [True, False]:
raise SQLParseError('Invalid value for indent_tabs: %r' % indent_tabs)
@@ -130,6 +137,11 @@ def build_filter_stack(stack, options):
width=options['indent_width'],
wrap_after=options['wrap_after']))
+ if options.get('reindent_aligned', False):
+ stack.enable_grouping()
+ stack.stmtprocess.append(
+ filters.AlignedIndentFilter(char=options['indent_char']))
+
if options.get('right_margin'):
stack.enable_grouping()
stack.stmtprocess.append(