annotate Tools/scripts/lfcr.py @ 67467:abe201dfd3dc 3.1

Merged revisions 87861,87863 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87861 | antoine.pitrou | 2011-01-08 11:23:29 +0100 (sam., 08 janv. 2011) | 3 lines Fix test_ssl after r87849 ........ r87863 | antoine.pitrou | 2011-01-08 11:28:11 +0100 (sam., 08 janv. 2011) | 3 lines Add EHOSTUNREACH ('No route to host') to the errnos trapped by transient_internet(). ........
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 08 Jan 2011 10:31:09 +0000
parents 46625e6122e9
children fcfe324663a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9099
728bbeb9e4f9 Utility to replace LF with CRLF in argument files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #! /usr/bin/env python
728bbeb9e4f9 Utility to replace LF with CRLF in argument files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
728bbeb9e4f9 Utility to replace LF with CRLF in argument files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 "Replace LF with CRLF in argument files. Print names of changed files."
728bbeb9e4f9 Utility to replace LF with CRLF in argument files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
11763
9876a64c181a Patch by Gerrit Holl:
Guido van Rossum <guido@python.org>
parents: 9102
diff changeset
5 import sys, re, os
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
6
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
7 def main():
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
8 for filename in sys.argv[1:]:
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
9 if os.path.isdir(filename):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 33074
diff changeset
10 print(filename, "Directory!")
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
11 continue
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
12 data = open(filename, "rb").read()
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
13 if '\0' in data:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 33074
diff changeset
14 print(filename, "Binary!")
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
15 continue
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
16 newdata = re.sub("\r?\n", "\r\n", data)
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
17 if newdata != data:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 33074
diff changeset
18 print(filename)
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
19 f = open(filename, "wb")
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
20 f.write(newdata)
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
21 f.close()
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
22
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
23 if __name__ == '__main__':
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 29102
diff changeset
24 main()