|
2 | 2 |
|
3 | 3 | from pydatastructs.utils.tests.test_code_quality import _list_files
|
4 | 4 |
|
| 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 | + |
5 | 14 |
|
6 | 15 | def update_version_in_files(file_paths, origin_version, new_version):
|
7 | 16 | """
|
@@ -43,11 +52,10 @@ def main():
|
43 | 52 | origin_version, new_version = sys.argv[1], sys.argv[2]
|
44 | 53 | print(f'Updating version number from {origin_version} to {new_version}...')
|
45 | 54 |
|
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)) |
51 | 59 |
|
52 | 60 | was_updated = update_version_in_files(
|
53 | 61 | file_paths, origin_version, new_version)
|
|
0 commit comments