-
Notifications
You must be signed in to change notification settings - Fork 4
/
updateVersion.py
67 lines (51 loc) · 2.43 KB
/
updateVersion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/local/bin/python3
import os
def changeHeader(directory, startPatternVersion, newLineVersion, startPatternCopyright, newLineCopyright, extension = (".h", ".cpp")):
for filename in os.listdir(directory):
if os.path.isdir(directory + "/" + filename):
changeHeader(directory + "/" + filename, startPatternVersion, newLineVersion, startPatternCopyright, newLineCopyright, extension)
elif filename.endswith(extension):
fullName = directory + '/' + filename
with open(fullName) as f:
lines = f.readlines()
toChange = False
if len(lines) > 1:
if lines[0].startswith(startPatternVersion):
lines[0] = newLineVersion
toChange = True
if lines[1].startswith(startPatternCopyright):
lines[1] = newLineCopyright
toChange = True
if toChange:
with open(fullName, "w") as f:
f.writelines(lines)
else:
print(directory + "/" + filename)
#### Do not forget to change the version number in the variable version in the Various/Constants.cpp file
# change license cpp files
startPatternVersion = "/* MixtComp "
newLineVersion = "/* MixtComp version 4 - july 2019\n"
startPatternCopyright = " * Copyright"
newLineCopyright = " * Copyright (C) Inria - Université de Lille - CNRS */\n"
extension = (".h", ".cpp")
directories = ["MixtComp/src/lib/", "MixtComp/src/utest/", "MixtComp/src/json/"]
for directory in directories:
changeHeader(directory, startPatternVersion, newLineVersion, startPatternCopyright, newLineCopyright, extension)
# change license R files
startPatternVersion = "# MixtComp "
newLineVersion = "# MixtComp version 4 - july 2019\n"
startPatternCopyright = "# Copyright"
newLineCopyright = "# Copyright (C) Inria - Université de Lille - CNRS\n"
extension = (".R", ".r")
directories = ["RMixtCompIO", "RMixtCompHier", "RMixtCompUtilities", "RMixtComp", "RJMixtComp"]
for directory in directories:
changeHeader(directory, startPatternVersion, newLineVersion, startPatternCopyright, newLineCopyright, extension)
# change license R files
startPatternVersion = "/* MixtComp "
newLineVersion = "/* MixtComp version 4 - july 2019\n"
startPatternCopyright = " * Copyright"
newLineCopyright = " * Copyright (C) Inria - Université de Lille - CNRS */\n"
extension = (".h", ".cpp")
directories = ["RMixtCompIO/src", "RMixtCompIO/src/test"]
for directory in directories:
changeHeader(directory, startPatternVersion, newLineVersion, startPatternCopyright, newLineCopyright, extension)