3 # file ReplaceValues.py
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
8 # author: Kornel Benko, kornel@lyx.org
10 # Syntax: ReplaceValues.py [<var1>=<Subst1> [<var2>=<Subst> ...]] <Inputfile> [<Inputfile> ...]
15 Subst = {} # map of desired substitutions
19 matchingS = "\\b|\\b".join(Subst.keys())
20 pattern = "".join(["(.*)(\\b", matchingS, "\\b)(.*)"])
21 return re.compile(pattern)
23 def SubstituteDataInLine(line):
25 m = prog.match(result)
27 return "".join([SubstituteDataInLine(m.group(1)),
29 SubstituteDataInLine(m.group(3))])
33 def SubstituteDataInFile(InFile):
34 for line in open(InFile):
35 print SubstituteDataInLine(line[:-1])
37 ##########################################
42 del args[0] # we don't need the name ot this script
45 entry = args[0].split("=",1)
53 SubstituteDataInFile(args[0])