summaryrefslogtreecommitdiff
path: root/sqlparse/formatter.py
diff options
context:
space:
mode:
authorJesús Leganés Combarro <piranna@gmail.com>2012-06-10 05:37:08 -0700
committerJesús Leganés Combarro <piranna@gmail.com>2012-06-10 05:37:08 -0700
commit89ef6078335ee9ec8cf816b0feb2668b4456c368 (patch)
tree4ecb8158f880382874875b52640a54bf6df25900 /sqlparse/formatter.py
parent1dfef65f69db96649f82db4173a8dad87dda4e0a (diff)
parent378f7a4b1f0b7a63e19075b9007aae25f272f344 (diff)
downloadsqlparse-milestone_0.1.5.tar.gz
Merge pull request #70 from piranna/milestone_0.1.5milestone_0.1.5
Milestone 0.1.5
Diffstat (limited to 'sqlparse/formatter.py')
-rw-r--r--sqlparse/formatter.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py
index f182850..39e5d28 100644
--- a/sqlparse/formatter.py
+++ b/sqlparse/formatter.py
@@ -9,6 +9,9 @@ from sqlparse import SQLParseError
from sqlparse import filters
+INDENT_WIDTH = 2
+
+
def validate_options(options):
"""Validates options."""
@@ -57,7 +60,7 @@ def validate_options(options):
options['indent_char'] = ' '
# indent_width
- indent_width = options.get('indent_width', 2)
+ indent_width = options.get('indent_width', INDENT_WIDTH)
try:
indent_width = int(indent_width)
except (TypeError, ValueError):
@@ -70,7 +73,7 @@ def validate_options(options):
# right_margin
right_margin = options.get('right_margin', None)
- if right_margin is not None:
+ if right_margin:
try:
right_margin = int(right_margin)
except (TypeError, ValueError):
@@ -112,7 +115,8 @@ def build_filter_stack(stack, options):
stack.enable_grouping()
stack.stmtprocess.append(
filters.ReindentFilter(char=options['indent_char'],
- width=options['indent_width']))
+ width=options['indent_width'],
+ line_width=options['right_margin']))
if options.get('right_margin', False):
stack.enable_grouping()