#!/usr/bin/python # -*- coding: utf-8 -*- # $Id$ # $HeadURL$ # $Author$ import re,os,sys rx1 = re.compile('(@RDE_HEADER@[ ]*\n[ \*]*)') rx2 = re.compile('(\\$Id: ([^ ]*) ([^ ]*).*)') rx3 = re.compile('.*\\$HeadURL:.*\n') rx4 = re.compile('(\\$Author: ([^ ]*).*)') def replace_svn_keywords(filename): print "fixing %s" % filename input_file = open(filename, "r") output = input_file.read() input_file.close() output = rx1.sub('\\\\brief ', output) output = rx2.sub('\\\\file \\2\n * \\\\version \\3', output) output = rx3.sub('', output) output = rx4.sub('\\\\author \\2', output) output_file = open(filename, "w") output_file.write(output) output_file.close() nargs = len(sys.argv) if nargs != 2 or not os.path.isdir(sys.argv[1]): print "usage: %s " sys.exit(1) for path, subdirs, files in os.walk(sys.argv[1]): files.extend(subdirs) for name in files: if name.endswith('.c') or \ name.endswith('.h') or \ name.endswith('.cpp') or \ name.endswith('.hpp'): replace_svn_keywords(os.path.join(path, name))