diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-10 14:13:56 +0200 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-10 14:13:56 +0200 |
| commit | 4983ec8789b3358801243fc7cd92c398674878ea (patch) | |
| tree | 0da15c957dbbc1309127084fa7b7054fdaa4e931 /sqlparse/formatter.py | |
| parent | 05d1276cf64d875ebc7a34126f096a271d11e4da (diff) | |
| parent | 378f7a4b1f0b7a63e19075b9007aae25f272f344 (diff) | |
| download | sqlparse-4983ec8789b3358801243fc7cd92c398674878ea.tar.gz | |
Merge branch 'milestone_0.1.5' into milestone_0.2.0
Conflicts:
sqlparse/filters.py
sqlparse/formatter.py
Diffstat (limited to 'sqlparse/formatter.py')
| -rw-r--r-- | sqlparse/formatter.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py index 75f21a8..edbafa1 100644 --- a/sqlparse/formatter.py +++ b/sqlparse/formatter.py @@ -13,6 +13,9 @@ class SQLParseError(Exception): """Base class for exceptions in this module.""" +INDENT_WIDTH = 2 + + def validate_options(options): """Validates options.""" kwcase = options.get('keyword_case', None) @@ -50,7 +53,9 @@ def validate_options(options): options['indent_char'] = '\t' else: options['indent_char'] = ' ' - indent_width = options.get('indent_width', 2) + + # indent_width + indent_width = options.get('indent_width', INDENT_WIDTH) try: indent_width = int(indent_width) except (TypeError, ValueError): @@ -60,7 +65,7 @@ def validate_options(options): options['indent_width'] = indent_width 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): @@ -102,7 +107,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() |
