]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/strip-whitespace.py
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scripts / auxiliar / strip-whitespace.py
1 #!/usr/bin/env python
2
3 # This script removes trailing whitespace from files.
4 # It doesn't remove trailing newlines.
5 # As a side-effect, it converts line endings to Unix-style (LF).
6
7 import os, sys
8
9 # Iterate through all arguments.  When the script is called
10 # with a wildcard (for example 'remove-trailing-whitespace.py *'),
11 # it's the *shell* that will expand the wildcard, and pass all
12 # resulting paths as arguments to the script.
13
14 for pathname in sys.argv[1:]:
15     if os.path.isfile(pathname):
16         fd = open(pathname,mode='U') # open in universal newline mode
17         lines = []
18         for line in fd.readlines():
19             lines.append( line.rstrip() )
20         fd.close()
21
22         fd = open(pathname,mode='w')
23         fd.seek(0)
24         for line in lines:
25             fd.write(line+'\n')
26         fd.close()