@@ -606,15 +606,18 @@ def format_single_fline(f_line, whitespace, linebreak_pos, ampersand_sep,
606606 # 4: arithm. operators plus and minus
607607 # 5: arithm. operators multiply and divide
608608 # 6: print / read statements
609+ # 7: select type components
609610
610611 if whitespace == 0 :
611- spacey = [0 , 0 , 0 , 0 , 0 , 0 , 0 ]
612+ spacey = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
612613 elif whitespace == 1 :
613- spacey = [1 , 1 , 1 , 1 , 0 , 0 , 1 ]
614+ spacey = [1 , 1 , 1 , 1 , 0 , 0 , 1 , 0 ]
614615 elif whitespace == 2 :
615- spacey = [1 , 1 , 1 , 1 , 1 , 0 , 1 ]
616+ spacey = [1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 ]
616617 elif whitespace == 3 :
617- spacey = [1 , 1 , 1 , 1 , 1 , 1 , 1 ]
618+ spacey = [1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ]
619+ elif whitespace == 4 :
620+ spacey = [1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
618621 else :
619622 raise NotImplementedError ("unknown value for whitespace" )
620623
@@ -744,6 +747,17 @@ def add_whitespace_charwise(line, spacey, filename, line_nr):
744747 spacey [0 ] + rhs .lstrip (' ' )
745748 line_ftd = line_ftd .rstrip (' ' )
746749
750+ # format type selector %
751+ if char == "%" :
752+ lhs = line_ftd [:pos + offset ]
753+ rhs = line_ftd [pos + 1 + offset :]
754+ line_ftd = lhs .rstrip (' ' ) \
755+ + ' ' * spacey [7 ] \
756+ + char \
757+ + ' ' * spacey [7 ] \
758+ + rhs .lstrip (' ' )
759+ line_ftd = line_ftd .rstrip (' ' )
760+
747761 # format .NOT.
748762 if re .search (r"^\.NOT\." , line [pos :pos + 5 ], RE_FLAGS ):
749763 lhs = line_ftd [:pos + offset ]
@@ -1318,7 +1332,12 @@ def run(argv=sys.argv): # pragma: no cover
13181332 parser .add_argument ("-i" , "--indent" , type = int , default = 3 ,
13191333 help = "relative indentation width" )
13201334 parser .add_argument ("-w" , "--whitespace" , type = int ,
1321- choices = range (0 , 4 ), default = 2 , help = "Amount of whitespace" )
1335+ choices = range (0 , 5 ), default = 2 , help = "Amount of whitespace - "
1336+ " 0: minimal whitespace"
1337+ " | 1: operators (except arithmetic), print/read"
1338+ " | 2: operators, print/read, plus/minus"
1339+ " | 3: operators, print/read, plus/minus, muliply/divide"
1340+ " | 4: operators, print/read, plus/minus, muliply/divide, type component selector" )
13221341 parser .add_argument ("--disable-indent" , action = 'store_true' , default = False , help = "don't impose indentation" )
13231342 parser .add_argument ("--disable-whitespace" , action = 'store_true' , default = False , help = "don't impose whitespace formatting" )
13241343 parser .add_argument ("--strip-comments" , action = 'store_true' , default = False , help = "strip whitespaces before comments" )
0 commit comments