@@ -52,22 +52,33 @@ def validate_options(options):
5252 % reindent )
5353 elif reindent :
5454 options ['strip_whitespace' ] = True
55+
5556 indent_tabs = options .get ('indent_tabs' , False )
5657 if indent_tabs not in [True , False ]:
5758 raise SQLParseError ('Invalid value for indent_tabs: %r' % indent_tabs )
5859 elif indent_tabs :
5960 options ['indent_char' ] = '\t '
6061 else :
6162 options ['indent_char' ] = ' '
63+
6264 indent_width = options .get ('indent_width' , 2 )
6365 try :
6466 indent_width = int (indent_width )
6567 except (TypeError , ValueError ):
6668 raise SQLParseError ('indent_width requires an integer' )
6769 if indent_width < 1 :
68- raise SQLParseError ('indent_width requires an positive integer' )
70+ raise SQLParseError ('indent_width requires a positive integer' )
6971 options ['indent_width' ] = indent_width
7072
73+ wrap_after = options .get ('wrap_after' , 0 )
74+ try :
75+ wrap_after = int (wrap_after )
76+ except (TypeError , ValueError ):
77+ raise SQLParseError ('wrap_after requires an integer' )
78+ if wrap_after < 0 :
79+ raise SQLParseError ('wrap_after requires a positive integer' )
80+ options ['wrap_after' ] = wrap_after
81+
7182 right_margin = options .get ('right_margin' , None )
7283 if right_margin is not None :
7384 try :
@@ -115,7 +126,8 @@ def build_filter_stack(stack, options):
115126 stack .enable_grouping ()
116127 stack .stmtprocess .append (
117128 filters .ReindentFilter (char = options ['indent_char' ],
118- width = options ['indent_width' ]))
129+ width = options ['indent_width' ],
130+ wrap_after = options ['wrap_after' ]))
119131
120132 if options .get ('right_margin' , False ):
121133 stack .enable_grouping ()
0 commit comments