diff --git a/TOOLS/dylib_unhell.py b/TOOLS/dylib_unhell.py index 871cd5d711..efd389a068 100755 --- a/TOOLS/dylib_unhell.py +++ b/TOOLS/dylib_unhell.py @@ -216,7 +216,7 @@ def process_swift_libraries(binary): def process_vulkan_loader(binary, loader_name, loader_relative_folder, library_node): # https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderDriverInterface.md#example-macos-driver-search-path # https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderLayerInterface.md#macos-layer-discovery - loaderSystemSearchFolders = [ + loader_system_search_folders = [ os.path.join(os.path.expanduser("~"), ".config", loader_relative_folder), os.path.join("/etc/xdg", loader_relative_folder), os.path.join("/usr/local/etc", loader_relative_folder), @@ -227,50 +227,52 @@ def process_vulkan_loader(binary, loader_name, loader_relative_folder, library_n os.path.join(get_homebrew_prefix(), "share", loader_relative_folder), ] - loaderSystemFolder = "" - for loaderSystemSearchFolder in loaderSystemSearchFolders: - if os.path.exists(loaderSystemSearchFolder): - loaderSystemFolder = loaderSystemSearchFolder + loader_system_folder = "" + for loader_system_search_folder in loader_system_search_folders: + if os.path.exists(loader_system_search_folder): + loader_system_folder = loader_system_search_folder break - if not loaderSystemFolder: + if not loader_system_folder: print(">>> could not find loader folder " + loader_relative_folder) return - loaderBundleFolder = os.path.join(resources_path(binary), loader_relative_folder) - loaderSystemPath = os.path.join(loaderSystemFolder, loader_name) - loaderBundlePath = os.path.join(loaderBundleFolder, loader_name) - libraryRelativeFolder = "../../../Frameworks/" + loader_bundle_folder = os.path.join(resources_path(binary), loader_relative_folder) + loader_system_path = os.path.join(loader_system_folder, loader_name) + loader_bundle_path = os.path.join(loader_bundle_folder, loader_name) + library_relative_folder = "../../../Frameworks/" - if not os.path.exists(loaderSystemPath): + if not os.path.exists(loader_system_path): print(">>> could not find loader " + loader_name) return - if not os.path.exists(loaderBundleFolder): - os.makedirs(loaderBundleFolder) + if not os.path.exists(loader_bundle_folder): + os.makedirs(loader_bundle_folder) - loaderSystemFile = open(loaderSystemPath) - loaderJsonData = json.load(loaderSystemFile) - libraryPath = loaderJsonData[library_node]["library_path"] - librarySystemPath = os.path.join(loaderSystemFolder, libraryPath) + loader_system_file = open(loader_system_path) + loader_json_data = json.load(loader_system_file) + library_path = loader_json_data[library_node]["library_path"] + library_system_path = os.path.join(loader_system_folder, library_path) - if not os.path.exists(librarySystemPath): - print(">>> could not find loader library " + librarySystemPath) + if not os.path.exists(library_system_path): + print(">>> could not find loader library " + library_system_path) return print(">>> modifiying and writing loader json " + loader_name) - loaderBundleFile = open(loaderBundlePath, "w") - loaderLibraryName = os.path.basename(librarySystemPath) - library_path = os.path.join(libraryRelativeFolder, loaderLibraryName) - loaderJsonData[library_node]["library_path"] = library_path - json.dump(loaderJsonData, loaderBundleFile, indent=4) + loader_bundle_file = open(loader_bundle_path, "w") + loader_library_name = os.path.basename(library_system_path) + library_path = os.path.join(library_relative_folder, loader_library_name) + loader_json_data[library_node]["library_path"] = library_path + json.dump(loader_json_data, loader_bundle_file, indent=4) - print(">>> copying loader library " + loaderLibraryName) - frameworkBundleFolder = os.path.join(loaderBundleFolder, libraryRelativeFolder) - if not os.path.exists(frameworkBundleFolder): - os.makedirs(frameworkBundleFolder) - library_target_path = os.path.join(frameworkBundleFolder, loaderLibraryName) - shutil.copy(librarySystemPath, library_target_path) + print(">>> copying loader library " + loader_library_name) + framework_bundle_folder = os.path.join( + loader_bundle_folder, library_relative_folder + ) + if not os.path.exists(framework_bundle_folder): + os.makedirs(framework_bundle_folder) + library_target_path = os.path.join(framework_bundle_folder, loader_library_name) + shutil.copy(library_system_path, library_target_path) def remove_dev_tools_rapths(binary): for path in get_rpaths_dev_tools(binary): diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py index 9de9b07340..37ae86df90 100755 --- a/TOOLS/matroska.py +++ b/TOOLS/matroska.py @@ -249,9 +249,6 @@ elements_matroska = ( def byte2num(s): return int(hexlify(s), 16) -class EOF(Exception): - pass - def camelcase_to_words(name): parts = [] start = 0 @@ -315,7 +312,7 @@ def printf(out, *args): out.write(" ".join(str(x) for x in args)) out.write("\n") -def generate_C_header(out): +def generate_c_header(out): printf(out, "// Generated by TOOLS/matroska.py, do not edit manually") printf(out) @@ -348,7 +345,7 @@ def generate_C_header(out): for el in elementlist)) -def generate_C_definitions(out): +def generate_c_definitions(out): printf(out, "// Generated by TOOLS/matroska.py, do not edit manually") printf(out) for el in reversed(elementlist): @@ -367,7 +364,7 @@ def generate_C_definitions(out): def read(s, length): t = s.read(length) if len(t) != length: - raise EOF + raise EOFError return t def read_id(s): @@ -475,16 +472,16 @@ if __name__ == "__main__": parse_one(s, 0, None, 1 << 63) if sys.argv[1] == "--generate-header": - generate_C_header(open(sys.argv[2], "w")) + generate_c_header(open(sys.argv[2], "w")) elif sys.argv[1] == "--generate-definitions": - generate_C_definitions(open(sys.argv[2], "w")) + generate_c_definitions(open(sys.argv[2], "w")) else: s = open(sys.argv[1], "rb") while 1: start = s.tell() try: parse_toplevel(s) - except EOF: + except EOFError: if s.tell() != start: raise Exception("Unexpected end of file") break diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py index c21661c318..bf144fe012 100755 --- a/TOOLS/osxbundle.py +++ b/TOOLS/osxbundle.py @@ -40,8 +40,8 @@ def apply_plist_template(plist_file, version): def sign_bundle(binary_name): sign_directories = ["Contents/Frameworks", "Contents/MacOS"] - for dir in sign_directories: - resolved_dir = os.path.join(bundle_path(binary_name), dir) + for sign_dir in sign_directories: + resolved_dir = os.path.join(bundle_path(binary_name), sign_dir) for root, _dirs, files in os.walk(resolved_dir): for f in files: path = os.path.join(root, f) diff --git a/TOOLS/stats-conv.py b/TOOLS/stats-conv.py index d6baee5a0c..e217570a63 100755 --- a/TOOLS/stats-conv.py +++ b/TOOLS/stats-conv.py @@ -81,7 +81,7 @@ colors = [ (0.75, 0, 0.75), ] -def mkColor(t): +def mk_color(t): return pg.mkColor(int(t[0] * 255), int(t[1] * 255), int(t[2] * 255)) SCALE = 1e6 # microseconds to seconds @@ -174,7 +174,7 @@ for e in G.sevents: if cur not in G.curveno: G.curveno[cur] = 0 args = {"name": e.name,"antialias":True} - color = mkColor(colors[G.curveno[cur] % len(colors)]) + color = mk_color(colors[G.curveno[cur] % len(colors)]) if e.type == "event-signal": args["symbol"] = e.marker args["symbolBrush"] = pg.mkBrush(color, width=0) diff --git a/pyproject.toml b/pyproject.toml index be20dde845..f4b272337b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,8 @@ line-length = 100 select = [ "F", # pyflakes "E", "W", # pycodestyle + "N", # pep8-naming "UP", # pyupgrade + "A", # flake8-builtins "Q", # flake8-quotes ]