8
This file is part of the Grantlee template system.
10
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
12
This library is free software; you can redistribute it and/or
13
modify it under the terms of the GNU Lesser General Public
14
License as published by the Free Software Foundation; either version
15
2 of the Licence, or (at your option) any later version.
17
This library is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
Library General Public License for more details.
22
You should have received a copy of the GNU Lesser General Public
23
License along with this library. If not, see <http://www.gnu.org/licenses/>.
27
def updateFile(filename):
28
f = open(filename, "r")
32
content = content.strip()
34
if content.startswith("/*"):
35
bit, commentplus = content.split("/*", 1)
36
comment, after = commentplus.split("*/", 1)
38
f = open(filename, "w")
39
f.write(bit + licence + after + "\n\n")
42
f = open(filename, "w")
43
f.write(licence + "\n\n" + content + "\n\n")
46
# http://code.activestate.com/recipes/499305/
47
def locate(pattern, root=os.curdir):
48
'''Locate all files matching supplied filename pattern in and below
49
supplied root directory.'''
50
for path, dirs, files in os.walk(os.path.abspath(root)):
51
for filename in fnmatch.filter(files, pattern):
52
yield os.path.join(path, filename)
54
if __name__ == "__main__":
55
for filename in locate("*.cpp"):
58
for filename in locate("*.h"):