Cleanup: declare __all__ for many scripts in tools/

This commit is contained in:
Campbell Barton
2025-01-04 20:27:07 +11:00
parent 6f64d70e60
commit 5fe261c89d
61 changed files with 290 additions and 13 deletions

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import unittest import unittest
from check_utils import ( from check_utils import (

View File

@@ -2,6 +2,9 @@
# SPDX-FileCopyrightText: 2023 Blender Authors # SPDX-FileCopyrightText: 2023 Blender Authors
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import unittest import unittest

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import unittest import unittest
from check_utils import ( from check_utils import (

View File

@@ -4,6 +4,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
# Usage: ./check_release.py -- ../path/to/release/folder # Usage: ./check_release.py -- ../path/to/release/folder
__all__ = (
"main",
)
import unittest import unittest

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import os import os
from pathlib import Path from pathlib import Path
import re import re

View File

@@ -3,6 +3,11 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"ScriptUnitTesting",
"parseArguments",
"sliceCommandLineArguments",
)
import unittest import unittest

View File

@@ -14,6 +14,9 @@ You may pass the markdown text as an argument, e.g.
check_docs_code_layout.py --markdown=markdown.txt check_docs_code_layout.py --markdown=markdown.txt
""" """
__all__ = (
"main",
)
import os import os
import argparse import argparse

View File

@@ -2,6 +2,15 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"BUILD_DIR",
"IGNORE_CMAKE",
"IGNORE_SOURCE",
"IGNORE_SOURCE_MISSING",
"SOURCE_DIR",
"UTF8_CHECK",
)
import os import os
IGNORE_SOURCE = ( IGNORE_SOURCE = (

View File

@@ -8,6 +8,10 @@ noted by the date which must be included with the *DEPRECATED* comment.
Once this date is past, the code should be removed. Once this date is past, the code should be removed.
""" """
__all__ = (
"main",
)
import os import os
import datetime import datetime

View File

@@ -8,6 +8,9 @@ this script updates XML themes once new settings are added
./blender.bin --background --python tools/check_source/check_descriptions.py ./blender.bin --background --python tools/check_source/check_descriptions.py
""" """
__all__ = (
"main",
)
import bpy import bpy

View File

@@ -14,6 +14,9 @@ Then restore the headers to their original state:
python3 check_header_duplicate.py --restore python3 check_header_duplicate.py --restore
""" """
__all__ = (
"main",
)
import os import os
import sys import sys

View File

@@ -9,6 +9,10 @@ https://spdx.org/licenses/
This can be activated by calling "make check_licenses" from Blenders root directory. This can be activated by calling "make check_licenses" from Blenders root directory.
""" """
__all__ = (
"main",
)
import os import os
import argparse import argparse

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import os import os
from os.path import join from os.path import join

View File

@@ -2,6 +2,12 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"PATHS",
"PATHS_EXCLUDE",
"SOURCE_DIR",
)
import os import os
from typing import ( from typing import (
Any, Any,

View File

@@ -13,6 +13,9 @@ Script for checking source code spelling.
Currently only python source is checked. Currently only python source is checked.
""" """
__all__ = (
"main",
)
import os import os
import argparse import argparse

View File

@@ -4,6 +4,15 @@
# these must be all lower case for comparisons # these must be all lower case for comparisons
__all__ = (
"dict_custom",
"dict_ignore",
"dict_ignore_hyphenated_prefix",
"dict_ignore_hyphenated_suffix",
"directories_ignore",
"files_ignore",
)
dict_custom = { dict_custom = {
# Added to newer versions of the dictionary, # Added to newer versions of the dictionary,
# we can remove these when the updated word-lists have been applied to `aspell-en`. # we can remove these when the updated word-lists have been applied to `aspell-en`.

View File

@@ -5,6 +5,10 @@
# Checks for defines which aren't used anywhere. # Checks for defines which aren't used anywhere.
__all__ = (
"main",
)
import os import os
import sys import sys

View File

@@ -13,6 +13,11 @@ Invocation:
... defines and includes are optional ... defines and includes are optional
""" """
__all__ = (
"main",
)
import sys
# delay parsing functions until we need them # delay parsing functions until we need them
USE_LAZY_INIT = True USE_LAZY_INIT = True
@@ -380,9 +385,15 @@ def recursive_arg_sizes(node, ):
recursive_arg_sizes(c) recursive_arg_sizes(c)
def main() -> int:
# cache function sizes # cache function sizes
recursive_arg_sizes(tu.cursor) recursive_arg_sizes(tu.cursor)
_defs.update(defs_precalc) _defs.update(defs_precalc)
# --- second pass, check against def's # --- second pass, check against def's
file_check_arg_sizes(tu) file_check_arg_sizes(tu)
return 0
if __name__ == "__main__":
sys.exit(main)

View File

@@ -13,6 +13,10 @@ cd {BUILD_DIR}
python ../blender/tools/check_source/static_check_clang.py --match=".*" --checks=struct_comments python ../blender/tools/check_source/static_check_clang.py --match=".*" --checks=struct_comments
""" """
__all__ = (
"main",
)
import argparse import argparse
import os import os

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import project_source_info import project_source_info
import subprocess import subprocess
import sys import sys

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import project_source_info import project_source_info
import subprocess import subprocess
import sys import sys

View File

@@ -21,6 +21,11 @@ To validate that things are registered correctly:
3. Run `info frame-filter` and check for `blender-frame-filters`. 3. Run `info frame-filter` and check for `blender-frame-filters`.
''' '''
__all__ = (
# Not used externally but functions as a `main`.
"register",
)
import gdb import gdb
import functools import functools
from contextlib import contextmanager from contextlib import contextmanager
@@ -675,4 +680,5 @@ def register():
gdb.frame_filters[frame_filter.name] = frame_filter gdb.frame_filters[frame_filter.name] = frame_filter
if __name__ == "__main__":
register() register()

View File

@@ -12,6 +12,10 @@ Example:
git_sort_commits.py < commits.txt git_sort_commits.py < commits.txt
""" """
__all__ = (
"main",
)
import sys import sys
import os import os

View File

@@ -10,6 +10,15 @@
# and https://pypi.org/project/blender-asset-tracer/ # and https://pypi.org/project/blender-asset-tracer/
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
__all__ = (
"open_blend",
# Expose for `wrapper_type` argument to `open_blend`.
"BlendFile",
"BlendFileRaw",
)
import gzip import gzip
import logging import logging
import os import os

View File

@@ -5,6 +5,15 @@
# Simple module for inspecting GITEA users, pulls and issues. # Simple module for inspecting GITEA users, pulls and issues.
__all__ = (
"git_username_detect",
"gitea_json_activities_get",
"gitea_json_issue_events_filter",
"gitea_json_issue_get",
"gitea_json_issues_search",
"gitea_user_get",
)
import datetime import datetime
import json import json
import urllib.error import urllib.error

View File

@@ -10,6 +10,9 @@ Example usage:
python ./issues_module_listing.py --severity High python ./issues_module_listing.py --severity High
""" """
__all__ = (
"main",
)
import argparse import argparse
import dataclasses import dataclasses

View File

@@ -12,6 +12,9 @@ Example usage:
python ./issues_needing_info.py --username mano-wii python ./issues_needing_info.py --username mano-wii
""" """
__all__ = (
"main",
)
import argparse import argparse
import datetime import datetime

View File

@@ -15,6 +15,10 @@ Example usage:
python ./weekly_report.py --username mano-wii python ./weekly_report.py --username mano-wii
""" """
__all__ = (
"main",
)
import argparse import argparse
import datetime import datetime

View File

@@ -16,6 +16,9 @@ Piping from the standard-input is also supported:
The text is printed to the standard output. The text is printed to the standard output.
""" """
__all__ = (
"main",
)
import argparse import argparse
import multiprocessing import multiprocessing

View File

@@ -13,6 +13,10 @@ Example use a custom range:
authors_git_gen.py --source=/src/blender --range=SHA1..HEAD authors_git_gen.py --source=/src/blender --range=SHA1..HEAD
""" """
__all__ = (
"main",
)
# NOTE: this shares the basic structure with `credits_git_gen.py`, # NOTE: this shares the basic structure with `credits_git_gen.py`,
# however details differ enough for them to be separate scripts. # however details differ enough for them to be separate scripts.
# Improvements to this script may apply there too. # Improvements to this script may apply there too.

View File

@@ -3,6 +3,11 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import subprocess import subprocess
import os import os
from os.path import join from os.path import join

View File

@@ -2,6 +2,12 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"PATHS",
"PATHS_EXCLUDE",
"SOURCE_DIR",
)
import os import os
from collections.abc import ( from collections.abc import (

View File

@@ -32,6 +32,10 @@ To check a .blend file instead of outputting its JSon version (use explicit -o o
./blend2json.py -c foo.blend ./blend2json.py -c foo.blend
""" """
__all__ = (
"main",
)
FILTER_DOC = """ FILTER_DOC = """
Each generic filter is made of three arguments, the include/exclude toggle ('+'/'-'), a regex to match against the name Each generic filter is made of three arguments, the include/exclude toggle ('+'/'-'), a regex to match against the name

View File

@@ -28,6 +28,9 @@ config = [
("rmb_action", ('TWEAK', 'FALLBACK_TOOL')), ("rmb_action", ('TWEAK', 'FALLBACK_TOOL')),
] ]
""" """
__all__ = (
"main",
)
import os import os
import sys import sys

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import os import os
import subprocess import subprocess
import sys import sys

View File

@@ -16,6 +16,10 @@ eg:
./tools/utils/blender_theme_as_c.py $(find ~/.config/blender -name "userpref.blend" | sort | tail -1) ./tools/utils/blender_theme_as_c.py $(find ~/.config/blender -name "userpref.blend" | sort | tail -1)
""" """
__all__ = (
"main",
)
C_SOURCE_HEADER = r'''/* SPDX-FileCopyrightText: 2018 Blender Authors C_SOURCE_HEADER = r'''/* SPDX-FileCopyrightText: 2018 Blender Authors
* *

View File

@@ -12,6 +12,10 @@ Example use a custom range:
credits_git_gen.py --source=/src/blender --range=SHA1..HEAD credits_git_gen.py --source=/src/blender --range=SHA1..HEAD
""" """
__all__ = (
"main",
)
# NOTE: this shares the basic structure with `credits_git_gen.py`, # NOTE: this shares the basic structure with `credits_git_gen.py`,
# however details differ enough for them to be separate scripts. # however details differ enough for them to be separate scripts.

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import argparse import argparse
import re import re
import shutil import shutil

View File

@@ -11,6 +11,11 @@ Example use:
(gdb) source tools/utils/gdb_struct_repr_c99.py (gdb) source tools/utils/gdb_struct_repr_c99.py
(gdb) print_struct_c99 scene->toolsettings (gdb) print_struct_c99 scene->toolsettings
''' '''
__all__ = (
"main",
)
import sys
class PrintStructC99(gdb.Command): class PrintStructC99(gdb.Command):
@@ -46,6 +51,7 @@ class PrintStructC99(gdb.Command):
print(' ' * hs + '.' + rr_s[0] + '= ' + rr_rval) print(' ' * hs + '.' + rr_s[0] + '= ' + rr_rval)
def main() -> int:
print('Running GDB from: {:s}\n'.format(gdb.PYTHONDIR)) print('Running GDB from: {:s}\n'.format(gdb.PYTHONDIR))
gdb.execute("set print pretty") gdb.execute("set print pretty")
gdb.execute('set pagination off') gdb.execute('set pagination off')
@@ -53,3 +59,8 @@ gdb.execute('set print repeats 0')
gdb.execute('set print elements unlimited') gdb.execute('set print elements unlimited')
# instantiate # instantiate
PrintStructC99() PrintStructC99()
return 0
if __name__ == "__main__":
sys.exit(main())

View File

@@ -4,6 +4,13 @@
# Simple module for inspecting git commits # Simple module for inspecting git commits
__all__ = (
"GitCommit",
"GitCommitIter",
"GitRepo",
)
import os import os
import subprocess import subprocess
import datetime import datetime

View File

@@ -12,6 +12,9 @@ Example usage:
./git_log_review_commits.py --source=../../.. --range=HEAD~40..HEAD --filter=BUGFIX ./git_log_review_commits.py --source=../../.. --range=HEAD~40..HEAD --filter=BUGFIX
""" """
__all__ = (
"main",
)
class _Getch: class _Getch:

View File

@@ -29,6 +29,10 @@ To exclude all commits from some given files, by sha1 or by commit message (from
""" """
__all__ = (
"main",
)
import os import os
import sys import sys
import io import io

View File

@@ -11,6 +11,10 @@
# * 403 Client Error: That means the token doesn't have the right scope. # * 403 Client Error: That means the token doesn't have the right scope.
# * 500 Server Error: The token is invalid. # * 500 Server Error: The token is invalid.
__all__ = (
"main",
)
import logging import logging
import os import os
import requests import requests

View File

@@ -6,6 +6,10 @@
# Created by Robert Wenzlaff (Det. Thorn). # Created by Robert Wenzlaff (Det. Thorn).
# Oct. 30, 2003 # Oct. 30, 2003
__all__ = (
"main",
)
import sys import sys
from tkinter import ( from tkinter import (
Button, Button,

View File

@@ -4,6 +4,9 @@
# Converts 32x32 XPM images written be the gimp to GL stipples # Converts 32x32 XPM images written be the gimp to GL stipples
# takes XPM files as arguments, prints out C style definitions. # takes XPM files as arguments, prints out C style definitions.
__all__ = (
"main",
)
import sys import sys
import os import os

View File

@@ -17,6 +17,10 @@ Example Use::
blender.bin -b --factory-startup my_shapes.blend --python make_shape_2d_from_blend.py blender.bin -b --factory-startup my_shapes.blend --python make_shape_2d_from_blend.py
''' '''
__all__ = (
"main",
)
import bpy import bpy
import os import os

View File

@@ -12,6 +12,10 @@ Example usage:
python3 tools/utils_api/bpy_introspect_ui.py python3 tools/utils_api/bpy_introspect_ui.py
""" """
__all__ = (
"main",
)
import sys import sys
ModuleType = type(sys) ModuleType = type(sys)

View File

@@ -21,6 +21,10 @@ Usage:
wheel_cleanup.py <path/to/installed/bpy/directory> wheel_cleanup.py <path/to/installed/bpy/directory>
""" """
__all__ = (
"main",
)
import argparse import argparse
import re import re
import shutil import shutil

View File

@@ -28,6 +28,10 @@ or added to the Blender UI translation table.
URL is the: url_manual_prefix + url_manual_mapping[#id] URL is the: url_manual_prefix + url_manual_mapping[#id]
''' '''
__all__ = (
"main",
)
import os import os
import argparse import argparse

View File

@@ -15,6 +15,10 @@ Otherwise you may call this script directly, for example:
./tools/utils_maintenance/autopep8_format_paths.py --changed-only tests/python ./tools/utils_maintenance/autopep8_format_paths.py --changed-only tests/python
""" """
__all__ = (
"main",
)
import os import os
import sys import sys

View File

@@ -8,6 +8,10 @@
# --enable-event-simulate \ # --enable-event-simulate \
# --python tools/utils_maintenance/blender_menu_search_coverage.py # --python tools/utils_maintenance/blender_menu_search_coverage.py
__all__ = (
"main",
)
import bpy import bpy
# Menu-ID -> class. # Menu-ID -> class.

View File

@@ -6,6 +6,10 @@
# #
# ./blender.bin --background --python ./tools/utils_maintenance/blender_update_themes.py # ./blender.bin --background --python ./tools/utils_maintenance/blender_update_themes.py
__all__ = (
"main",
)
import bpy import bpy
import os import os

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import os import os
import sys import sys

View File

@@ -11,6 +11,10 @@ There may be times this is needed, however they can typically be removed
and any errors caused can be added to the headers which require the forward declarations. and any errors caused can be added to the headers which require the forward declarations.
""" """
__all__ = (
"main",
)
import os import os
import sys import sys
import re import re

View File

@@ -11,6 +11,9 @@ While it can be called directly, you may prefer to run this from Blender's root
make format make format
""" """
__all__ = (
"main",
)
import argparse import argparse
import multiprocessing import multiprocessing

View File

@@ -8,6 +8,9 @@ Sorts CMake path lists
- Don't cross blank newline boundaries. - Don't cross blank newline boundaries.
- Don't cross different path prefix boundaries. - Don't cross different path prefix boundaries.
""" """
__all__ = (
"main",
)
import os import os
import sys import sys

View File

@@ -11,6 +11,10 @@ Note: currently this is limited to paths in "source/" and "intern/",
we could change this if it's needed. we could change this if it's needed.
""" """
__all__ = (
"main",
)
import argparse import argparse
import re import re
import subprocess import subprocess

View File

@@ -3,6 +3,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
# pylint: disable=missing-function-docstring, missing-module-docstring, missing-class-docstring # pylint: disable=missing-function-docstring, missing-module-docstring, missing-class-docstring
__all__ = (
"main",
)
import datetime import datetime
import itertools import itertools
import json import json

View File

@@ -2,6 +2,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"run",
)
from collections.abc import ( from collections.abc import (
Callable, Callable,
Iterator, Iterator,

View File

@@ -3,6 +3,10 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import os import os
from os.path import join from os.path import join

View File

@@ -2,6 +2,12 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"PATHS",
"SOURCE_DIR",
)
import os import os
PATHS = ( PATHS = (
"build_files/build_environment/cmake", "build_files/build_environment/cmake",