Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

root/branches/cherrypy-2.x/tools/linefeed.py

Revision 848 (checked in by rdelon, 3 years ago)

Fixed typo in test_states

Line 
1 #! /usr/bin/env python
2 "Replace CRLF with LF cherrypy files.  Print names of changed files."
3
4 import sys, os
5 import glob, os.path
6 import re
7
8 def main():
9     scriptdir = os.path.split(sys.argv[0])[0]
10     basepath = os.path.split(scriptdir)[0]
11     filelist = []
12     for directory in ['/tools','/cherrypy','/cherrypy/lib/filter','/',
13                       '/cherrypy/filters','/cherrypy/lib','/cherrypy/test',
14                       '/cherrypy/tutorial']:
15         filelist.extend(glob.glob(basepath+directory+'/*.py'))
16         filelist.extend(glob.glob(basepath+directory+'/*.conf'))
17         filelist.extend(glob.glob(basepath+directory+'/*.txt'))
18     for filename in filelist:
19         if os.path.isdir(filename):
20             print filename, "Directory!"
21             continue
22         data = open(filename, "rb").read()
23         if '\0' in data:
24             print filename, "Binary!"
25             continue
26         if os.path.splitext(filename)[1].lower() == '.txt':
27             newdata = data.replace('\n','\r\n')
28         else:
29             newdata = data.replace('\r\n','\n')
30         if newdata != data:
31             print filename
32             f = open(filename, "wb")
33             f.write(newdata)
34             f.close()
35
36 if __name__ == '__main__':
37     main()
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets