@@ -16,8 +16,8 @@ def main(args=None):
1616
1717 # Look for optional arguments:
1818 try :
19- opts , dirnames = getopt .getopt (args , "hsc " , ["help" ,"strip" ,"clean" ,
20- "eol=" ])
19+ opts , dirnames = getopt .getopt (args , "hvsbc " , ["help" ,"version" , " strip" , "blanks " ,"clean" ,
20+ "eol=" ])
2121 # If unknown option is given trigger the display message:
2222 except getopt .GetoptError :
2323 unknownOption (args )
@@ -35,8 +35,14 @@ def main(args=None):
3535 if opt in ("-h" ,"--help" ):
3636 usage (args )
3737 sys .exit (0 )
38+ elif opt in ("-v" ,"--version" ):
39+ os .system ('pip show ttws' )
40+ sys .exit (0 )
3841 elif opt in ("-c" ,"--clean" ):
3942 cleanOpt = True
43+ elif opt in ("-b" ,"--blanks" ):
44+ os .system ('for fn in `find -name "*.mo"`; do cat -s $fn >$fn.1; mv $fn.1 $fn; done' )
45+ sys .exit (0 )
4046 elif opt in ("-s" ,"--strip" ):
4147 stripOpt = True
4248 elif opt in ("--eol" ):
@@ -78,16 +84,15 @@ def main(args=None):
7884 else :
7985 print ("skipping file of type %s: %s" % (filetype , filepath ))
8086
81-
8287def usage (script_name ):
8388 """Help message on usage."""
8489 message = """
8590 Usage: ttws [OPTIONS] <directory> [<directory> ...]
8691
87- This script will recursively scan all text files in a given list of
88- directories and remove all trailing white space in every line as well
89- as multiple blank lines at the end of the file. Binary files and files
90- residing in '.bzr', '.cvs', '.git', '.hg', '.svn' directories are
92+ This script will recursively scan all text files in a given list of
93+ directories and remove all trailing white space in every line as well
94+ as multiple blank lines at the end of the file. Binary files and files
95+ residing in '.bzr', '.cvs', '.git', '.hg', '.svn' directories are
9196 skipped.
9297
9398 Since the main application is for Modelica projects it expects all files
@@ -103,6 +108,9 @@ def usage(script_name):
103108 -h, --help
104109 displays this help message
105110
111+ -v, --version
112+ displays version information
113+
106114 -s, --strip
107115 strips leading or trailing white spaces from info or
108116 revision strings that contain HTML documentation
@@ -124,9 +132,12 @@ def usage(script_name):
124132 Only use this if your code is under version control
125133 and in combination with a careful code-diff review.
126134
135+ -b, --blanks
136+ suppress repeated empty output lines from *.mo files
137+ (This option should not be run in combination with others.)
138+
127139 """ % (extstring , repr (os .linesep ))
128140 print (textwrap .dedent (message ))
129141
130-
131142if __name__ == "__main__" :
132143 sys .exit (main ())
0 commit comments