9 absexpanduser =
lambda x: os.path.abspath(os.path.expanduser(x))
12 description = (
"This script renames all instances of stub, Stub, and STUB "
13 "to the value given on the command line.")
14 parser = ap.ArgumentParser(description=description)
15 parser.add_argument(
'name', help=
"replacement for stub", default=
'name')
16 ns = parser.parse_args()
18 low, cap, upp = ns.name.lower(), ns.name.capitalize(), ns.name.upper()
19 stublow, stubcap, stubupp =
'stub',
'Stub',
'STUB'
20 mvfiles = glob(
'src/stub*')
22 d = os.path.dirname(f)
23 name = os.path.basename(f)
24 newname = os.path.join(d, name.replace(
'stub', low))
25 subprocess.call([
'git',
'mv',f,newname])
26 subprocess.call([
'git',
'commit',
'-m',
27 '"moves stubfile '.join(name).join(
'->').join(newname).join(
'"')])
29 files = [
'CMakeLists.txt',
'input/example.xml'] + glob(
'src/*')
31 with open(f,
'r') as inp:
33 s = s.replace('stubs', low)
34 s = s.replace(stublow, low)
35 s = s.replace(stubcap, cap)
36 s = s.replace(stubupp, upp)
38 d = os.path.dirname(f)
39 name = os.path.basename(f)
40 with open(os.path.join(d, name.replace(
'stub', low)),
'w')
as out:
43 if __name__ ==
"__main__":