[Commits] (bear) new function convertLineEndings
commits at osafoundation.org
commits at osafoundation.org
Mon Feb 7 18:56:55 PST 2005
Commit by: bear
Modified files:
hardhat/hardhatlib.py 1.86 1.87
Log message:
new function convertLineEndings
Walks thru distribution tree and converts any files that match *.txt
from linux line-endings to dos line-endings
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/hardhat/hardhatlib.py.diff?r1=text&tr1=1.86&r2=text&tr2=1.87
Index: hardhat/hardhatlib.py
diff -u hardhat/hardhatlib.py:1.86 hardhat/hardhatlib.py:1.87
--- hardhat/hardhatlib.py:1.86 Tue Jan 4 10:35:19 2005
+++ hardhat/hardhatlib.py Mon Feb 7 18:56:54 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.86 $"
-__date__ = "$Date: 2005/01/04 18:35:19 $"
+__version__ = "$Revision: 1.87 $"
+__date__ = "$Date: 2005/02/08 02:56:54 $"
__copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
__license__ = "GPL -- see LICENSE.txt"
@@ -120,15 +120,15 @@
CHANDLERHOME, CHANDLERBIN = getCHANDLERvars(buildenv)
- buildenv['sh'] = findInPath(buildenv['path'], "sh")
- buildenv['make'] = findInPath(buildenv['path'], "make")
- buildenv['cvs'] = findInPath(buildenv['path'], "cvs")
- buildenv['scp'] = findInPath(buildenv['path'], "scp")
- buildenv['tar'] = findInPath(buildenv['path'], "tar")
- buildenv['gzip'] = findInPath(buildenv['path'], "gzip")
- buildenv['zip'] = findInPath(buildenv['path'], "zip")
- buildenv['cvs'] = findInPath(buildenv['path'], "cvs")
- #buildenv['perl'] = findInPath(buildenv['path'], "perl")
+ buildenv['sh'] = findInPath(buildenv['path'], "sh")
+ buildenv['make'] = findInPath(buildenv['path'], "make")
+ buildenv['cvs'] = findInPath(buildenv['path'], "cvs")
+ buildenv['scp'] = findInPath(buildenv['path'], "scp")
+ buildenv['tar'] = findInPath(buildenv['path'], "tar")
+ buildenv['gzip'] = findInPath(buildenv['path'], "gzip")
+ buildenv['zip'] = findInPath(buildenv['path'], "zip")
+ buildenv['cvs'] = findInPath(buildenv['path'], "cvs")
+ #buildenv['perl'] = findInPath(buildenv['path'], "perl")
# set OS-specific variables
if buildenv['os'] == 'win':
@@ -1556,6 +1556,22 @@
"Running gzip on " + fileRoot + ".tar")
return fileRoot + ".tar.gz"
+def convertLineEndings(srcdir):
+ """Convert all .txt files in the distribution root to DOS style line endings"""
+ for name in os.listdir(srcdir):
+ fullpath = os.path.join(srcdir, name)
+ if os.path.isdir(fullpath):
+ convertLineEndings(fullpath)
+ else:
+ if fnmatch.fnmatch(name, "*.txt"):
+ if os.path.isfile(fullpath):
+ text = open(fullpath, "rb").read()
+ newtext = text.replace("\n", "\r\n")
+ if newtext != text:
+ f = open(fullpath, "wb")
+ f.write(newtext)
+ f.close()
+
def findInPath(path,fileName):
dirs = path.split(os.pathsep)
for dir in dirs:
More information about the Commits
mailing list