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