Cleanup: use main functions to allow importing scripts
Support importing scripts without running their logic to allow basic validation (see #130746). Parts of !131037 were used. Co-authored-by: Bastien Montagne <bastien@blender.org>
This commit is contained in:
@@ -83,9 +83,15 @@ def sort_struct_lists(fn: str, data_src: str) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
run(
|
||||
directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS],
|
||||
is_text=lambda fn: fn.endswith(SOURCE_EXT),
|
||||
text_operation=sort_struct_lists,
|
||||
use_multiprocess=True,
|
||||
)
|
||||
def main() -> int:
|
||||
run(
|
||||
directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS],
|
||||
is_text=lambda fn: fn.endswith(SOURCE_EXT),
|
||||
text_operation=sort_struct_lists,
|
||||
use_multiprocess=True,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
@@ -84,9 +84,15 @@ def clean_structs(fn: str, data_src: str) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
run(
|
||||
directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS],
|
||||
is_text=lambda fn: fn.endswith(SOURCE_EXT),
|
||||
text_operation=clean_structs,
|
||||
use_multiprocess=False,
|
||||
)
|
||||
def main() -> int:
|
||||
run(
|
||||
directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS],
|
||||
is_text=lambda fn: fn.endswith(SOURCE_EXT),
|
||||
text_operation=clean_structs,
|
||||
use_multiprocess=False,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
@@ -93,9 +93,15 @@ def sort_cmake_file_lists(fn: str, data_src: str) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
run(
|
||||
directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS],
|
||||
is_text=lambda fn: fn.endswith("CMakeLists.txt"),
|
||||
text_operation=sort_cmake_file_lists,
|
||||
use_multiprocess=True,
|
||||
)
|
||||
def main() -> int:
|
||||
run(
|
||||
directories=[os.path.join(SOURCE_DIR, d) for d in SOURCE_DIRS],
|
||||
is_text=lambda fn: fn.endswith("CMakeLists.txt"),
|
||||
text_operation=sort_cmake_file_lists,
|
||||
use_multiprocess=True,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user