@@ -17,8 +17,7 @@ def main(args=None):
1717
1818 # Look for optional arguments:
1919 try :
20- opts , dirnames = getopt .getopt (args , "hvsbc" , ["help" , "version" , "strip" , "blanks" , "clean" ,
21- "eol=" ])
20+ opts , dirnames = getopt .getopt (args , "hvsbcm" , ["help" , "version" , "strip" , "blanks" , "clean" , "multi" , "eol=" ])
2221 # If unknown option is given trigger the display message:
2322 except getopt .GetoptError :
2423 unknownOption (args )
@@ -30,6 +29,7 @@ def main(args=None):
3029
3130 # If help option is given display help otherwise display warning:
3231 cleanOpt = False
32+ multiOpt = False
3333 stripOpt = False
3434 eol = os .linesep
3535 for opt , arg in opts :
@@ -41,6 +41,8 @@ def main(args=None):
4141 sys .exit (0 )
4242 elif opt in ("-c" , "--clean" ):
4343 cleanOpt = True
44+ elif opt in ("-m" , "--multi" ):
45+ multiOpt = True
4446 elif opt in ("-b" , "--blanks" ):
4547 os .system ('for fn in `find -name "*.mo"`; do cat -s $fn >$fn.1; mv $fn.1 $fn; done' )
4648 sys .exit (0 )
@@ -73,15 +75,15 @@ def main(args=None):
7375 filetype = detecttype (filepath )
7476 if filetype is "mo" and cleanOpt is True :
7577 print ("trimming and cleaning %s" % filepath )
76- trimWhitespace (filepath , eol )
78+ trimWhitespace (filepath , multiOpt , eol )
7779 cleanAnnotation (filepath , eol )
7880 elif filetype is "mo" and stripOpt is True :
7981 print ("trimming and stripping %s" % filepath )
80- trimWhitespace (filepath , eol )
82+ trimWhitespace (filepath , multiOpt , eol )
8183 stripDocString (filepath , eol )
8284 elif filetype is "mo" or filetype is "text" :
8385 print ("trimming %s" % filepath )
84- trimWhitespace (filepath , eol )
86+ trimWhitespace (filepath , multiOpt , eol )
8587 else :
8688 print ("skipping file of type %s: %s" % (filetype , filepath ))
8789
@@ -134,6 +136,12 @@ def usage(script_name):
134136 Only use this if your code is under version control
135137 and in combination with a careful code-diff review.
136138
139+ -m, --multi
140+ Replaces multiple inline whitespaces by one whitespace.
141+ It ignores commented lines starting with '//'
142+ CAREFUL: It will damage whitespace sensitive documentation
143+ like verbatim code snippets!
144+
137145 -b, --blanks
138146 suppress repeated empty output lines from *.mo files
139147 (This option should not be run in combination with others.)
0 commit comments