@@ -15,61 +15,65 @@ def validate_options(options):
1515 """Validates options."""
1616 kwcase = options .get ('keyword_case' )
1717 if kwcase not in [None , 'upper' , 'lower' , 'capitalize' ]:
18- raise SQLParseError ('Invalid value for keyword_case: %r' % kwcase )
18+ raise SQLParseError ('Invalid value for keyword_case: '
19+ '{0!r}' .format (kwcase ))
1920
2021 idcase = options .get ('identifier_case' )
2122 if idcase not in [None , 'upper' , 'lower' , 'capitalize' ]:
22- raise SQLParseError ('Invalid value for identifier_case: %r' % idcase )
23+ raise SQLParseError ('Invalid value for identifier_case: '
24+ '{0!r}' .format (idcase ))
2325
2426 ofrmt = options .get ('output_format' )
2527 if ofrmt not in [None , 'sql' , 'python' , 'php' ]:
26- raise SQLParseError ('Unknown output format: %r' % ofrmt )
28+ raise SQLParseError ('Unknown output format: '
29+ '{0!r}' .format (ofrmt ))
2730
2831 strip_comments = options .get ('strip_comments' , False )
2932 if strip_comments not in [True , False ]:
30- raise SQLParseError ('Invalid value for strip_comments: %r '
31- % strip_comments )
33+ raise SQLParseError ('Invalid value for strip_comments: '
34+ '{0!r}' . format ( strip_comments ) )
3235
3336 space_around_operators = options .get ('use_space_around_operators' , False )
3437 if space_around_operators not in [True , False ]:
35- raise SQLParseError ('Invalid value for use_space_around_operators: %r '
36- % space_around_operators )
38+ raise SQLParseError ('Invalid value for use_space_around_operators: '
39+ '{0!r}' . format ( space_around_operators ) )
3740
3841 strip_ws = options .get ('strip_whitespace' , False )
3942 if strip_ws not in [True , False ]:
40- raise SQLParseError ('Invalid value for strip_whitespace: %r '
41- % strip_ws )
43+ raise SQLParseError ('Invalid value for strip_whitespace: '
44+ '{0!r}' . format ( strip_ws ) )
4245
4346 truncate_strings = options .get ('truncate_strings' )
4447 if truncate_strings is not None :
4548 try :
4649 truncate_strings = int (truncate_strings )
4750 except (ValueError , TypeError ):
48- raise SQLParseError ('Invalid value for truncate_strings: %r '
49- % truncate_strings )
51+ raise SQLParseError ('Invalid value for truncate_strings: '
52+ '{0!r}' . format ( truncate_strings ) )
5053 if truncate_strings <= 1 :
51- raise SQLParseError ('Invalid value for truncate_strings: %r '
52- % truncate_strings )
54+ raise SQLParseError ('Invalid value for truncate_strings: '
55+ '{0!r}' . format ( truncate_strings ) )
5356 options ['truncate_strings' ] = truncate_strings
5457 options ['truncate_char' ] = options .get ('truncate_char' , '[...]' )
5558
5659 reindent = options .get ('reindent' , False )
5760 if reindent not in [True , False ]:
58- raise SQLParseError ('Invalid value for reindent: %r '
59- % reindent )
61+ raise SQLParseError ('Invalid value for reindent: '
62+ '{0!r}' . format ( reindent ) )
6063 elif reindent :
6164 options ['strip_whitespace' ] = True
6265
6366 reindent_aligned = options .get ('reindent_aligned' , False )
6467 if reindent_aligned not in [True , False ]:
65- raise SQLParseError ('Invalid value for reindent_aligned: %r '
66- % reindent )
68+ raise SQLParseError ('Invalid value for reindent_aligned: '
69+ '{0!r}' . format ( reindent ) )
6770 elif reindent_aligned :
6871 options ['strip_whitespace' ] = True
6972
7073 indent_tabs = options .get ('indent_tabs' , False )
7174 if indent_tabs not in [True , False ]:
72- raise SQLParseError ('Invalid value for indent_tabs: %r' % indent_tabs )
75+ raise SQLParseError ('Invalid value for indent_tabs: '
76+ '{0!r}' .format (indent_tabs ))
7377 elif indent_tabs :
7478 options ['indent_char' ] = '\t '
7579 else :
0 commit comments