Skip to content

Commit ce1c52f

Browse files
committed
Update
1 parent 94bde60 commit ce1c52f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

version_tool.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
import sys
33

44
if len(sys.argv) != 3:
5-
raise ValueError('original version number and new version number are both needed!')
6-
7-
origin_version, new_version = sys.argv[1], sys.argv[2]
8-
9-
# file_path contains all files'(README, code, documentation source) paths that may contain version number.
10-
file_path = ['README.md', 'setup.py']
11-
12-
# Walk through directories to add all corresponding files' paths into file_path
13-
for root, _, files in os.walk('./pydatastructs'):
14-
for file in files:
15-
16-
if file.endswith('.py'):
17-
file_path.append(os.path.join(root, file))
18-
19-
for root, dirs, files in os.walk('./docs/source'):
20-
for file in files:
21-
if file.endswith('.rst') or file.endswith('.py'):
22-
file_path.append(os.path.join(root, file))
23-
24-
# Update version number everywhere
25-
for path in file_path:
26-
with open(path, 'r') as file:
27-
data = file.read()
28-
if origin_version in data:
29-
data = data.replace(origin_version, new_version)
30-
with open(path, 'w') as file:
31-
file.write(data)
32-
33-
print('Updated version number!')
5+
print('original version number and new version number are both needed!')
6+
else:
7+
origin_version, new_version = sys.argv[1], sys.argv[2]
8+
9+
# file_path contains all files'(README, code, documentation source) paths that may contain version number.
10+
file_path = ['README.md', 'setup.py']
11+
12+
# Walk through directories to add all corresponding files' paths into file_path
13+
for root, _, files in os.walk('./pydatastructs'):
14+
for file in files:
15+
16+
if file.endswith('.py'):
17+
file_path.append(os.path.join(root, file))
18+
19+
for root, dirs, files in os.walk('./docs/source'):
20+
for file in files:
21+
if file.endswith('.rst') or file.endswith('.py'):
22+
file_path.append(os.path.join(root, file))
23+
24+
# Update version number everywhere
25+
for path in file_path:
26+
with open(path, 'r') as file:
27+
data = file.read()
28+
if origin_version in data:
29+
data = data.replace(origin_version, new_version)
30+
with open(path, 'w') as file:
31+
file.write(data)
32+
33+
print('Updated version number!')

0 commit comments

Comments
 (0)