Skip to content

Commit 501f036

Browse files
committed
Cleaned up code for easier modification of files to be scanned
1 parent 221af24 commit 501f036

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

scripts/versioning/update_version.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
from pydatastructs.utils.tests.test_code_quality import _list_files
44

5+
# Files to be updated with the new version number
6+
# The first element of the tuple is the directory path
7+
# and the second element is a lambda function that
8+
# returns True if the file should be updated.
9+
FILES_TO_BE_SCANNED = {
10+
'pydatastructs': ('./pydatastructs', lambda _file: _file.endswith('.py')),
11+
'docs': ('./docs/source', lambda _file: _file.endswith('.rst') or _file.endswith('.py'))
12+
}
13+
514

615
def update_version_in_files(file_paths, origin_version, new_version):
716
"""
@@ -43,11 +52,10 @@ def main():
4352
origin_version, new_version = sys.argv[1], sys.argv[2]
4453
print(f'Updating version number from {origin_version} to {new_version}...')
4554

46-
pydatastructs_files = _list_files(lambda _file: _file.endswith('.py'),
47-
'./pydatastructs')
48-
docs_files = _list_files(lambda _file: _file.endswith('.rst') or _file.endswith('.py'),
49-
'./docs/source')
50-
file_paths = ['README.md', 'setup.py'] + pydatastructs_files + docs_files
55+
file_paths = ['README.md', 'setup.py']
56+
57+
for _, (dir_path, checker) in FILES_TO_BE_SCANNED.items():
58+
file_paths.extend(_list_files(checker, dir_path))
5159

5260
was_updated = update_version_in_files(
5361
file_paths, origin_version, new_version)

0 commit comments

Comments
 (0)