Experimental hacks with widget size
[mozilla-central.git] / build / win32 / mozilla-dos2unix.py
blobbfdbd6f7f4b8acb0147d50a829fa2b269df97956
1 #!/usr/bin/python
3 import sys
4 if not sys.platform == "win32":
5 raise Exception("This script was only meant for Windows.")
7 import os
9 def dos2unix(path):
10 print "dos2unix: %s" % path
12 inf = open(path, "r")
13 data = inf.read()
14 inf.close()
17 outf = open(path, "wb")
18 outf.write(data)
19 outf.close()
21 adminfiles = [
22 "Root",
23 "Repository",
24 "Entries",
25 "Entries.Log",
26 "Entries.Static",
27 "Tag",
28 "Notify",
29 "Template"
32 def walkdirectory(path):
33 if not os.path.exists(os.path.join(path, "CVS")):
34 return
36 print "Directory: %s" % path
38 for f in adminfiles:
39 cvsf = os.path.join(path, "CVS", f)
40 if os.path.exists(cvsf):
41 dos2unix(cvsf)
43 entries = open(os.path.join(path, "CVS", "Entries"), "r")
44 for entry in entries:
45 if entry == "D\n":
46 continue
48 (type, filename, rev, date, flags, extra) = entry.split('/')
49 if type == "D" or flags == "-kb" or rev[0] == "-":
50 continue
52 dos2unix(os.path.join(path, filename))
54 # Now walk subdirectories
55 for entry in os.listdir(path):
56 subdir = os.path.join(path, entry)
57 if os.path.isdir(subdir):
58 walkdirectory(subdir)
60 topsrcdir = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-3])
62 print """This command will convert the source tree at
63 %s
64 to an MSYS-compatible (unix mode) source tree. You can run this
65 command multiple times safely. Are you sure you want to continue (Y/N)? """ % topsrcdir,
66 sys.stdout.flush()
67 print
69 ask = raw_input()
70 if len(ask) == 0 or (ask[0] != "y" and ask[0] != "Y"):
71 raise Exception("User aborted action.")
73 walkdirectory(topsrcdir)