[Tutor] style ok?
Huuuuuu
mennosimons@gmx.net
Tue, 2 Apr 2002 12:58:52 +0200
Hi,
this is a tiny script that puts the cvs-keywords $Id$ and $Log$ at the
beginning and end of the specified files. It works as it is put below, but I
assume there are ways to do it more compact/beautiful.
Any comments?
Thanks,
willi
----------------- logidfiles.py ----------------------------
#!/usr/bin/python
import sys, string
files = sys.argv[1:]
print "logid. v1.0 \nFiles to logid: ",files
id = """/*
* $Id$
*/
"""
log = """
/*
* $Log$
*/
"""
def listify(l):
l = string.split(l, sep="\n")
l = [w+"\n" for w in l]
return l
id = listify(id)
log = listify(log)
for name in files:
f = open(name, "r+")
content = f.readlines()
content[0:0] = id
content[-1:] = log
f.seek(0)
f.writelines(content)
print name,"bearbeitet."