From d4ae84fba3f94a9f2c919e93c73eb48bc412ea87 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:46:31 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.13.2 → v0.17.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.13.2...v0.17.0) - [github.com/pre-commit/mirrors-clang-format: v19.1.4 → v23.1.3](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.4...v23.1.3) - [github.com/igorshubovych/markdownlint-cli: v0.47.0 → v0.49.1](https://github.com/igorshubovych/markdownlint-cli/compare/v0.47.0...v0.49.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c7c76716..b1219f275 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,21 +5,21 @@ repos: - id: cmake-format - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.2 + rev: v0.17.0 hooks: - id: ruff-check args: [ --fix ] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v19.1.4' + rev: 'v23.1.3' hooks: - id: clang-format types_or: [c++, c] exclude: '\.(m|mm)$' - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.47.0 + rev: v0.49.1 hooks: - id: markdownlint args: [--fix] From a248b7e4ad8a4f0e262b355a9dbf908d65756707 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:47:31 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- conan/scripts/export_recipes.py | 1 - conan/scripts/validate_packages_yml.py | 1 - .../rv-reference-manual-chapter-four.md | 37 +++++---- .../rv-reference-manual-chapter-two.md | 7 +- openrvcore-conanfile.py | 10 ++- src/bin/apps/rv/main.cpp | 2 +- src/bin/apps/rvpkg/main.cpp | 2 +- src/bin/mu/mu-interp/test/rng.py | 3 +- src/bin/nsapps/RV/main.cpp | 2 +- src/bin/python/py-interp/tests/test_SSL.py | 15 ++-- src/build/install_all_rvpkg.py | 1 - src/build/make_openssl.py | 6 +- src/build/make_pyside.py | 26 +++--- src/build/make_pyside6.py | 26 +++--- src/build/make_python.py | 52 ++++++------ .../patch_OCIO/ocio_pyopencolorio_patch.py | 25 +++--- src/build/patch_PySide2/windows_desktop.py | 8 +- src/build/remove_absolute_rpath.py | 3 +- src/build/sitecustomize.py | 2 +- src/build/test_python_distribution.py | 2 - src/build/test_python_imports.py | 1 - src/build/utils.py | 13 ++- src/lib/app/RvCommon/generate_theme.py | 31 ++++---- .../TwkMediaLibrary/TwkMediaLibrary/Library.h | 4 +- src/lib/app/py_rvui/rv/qtutils.py | 6 +- src/lib/app/py_rvui/rv/rvtypes.py | 11 +-- src/lib/app/py_rvui/rv_commands_setup.py | 1 + .../TwkContainer/TwkContainer/Properties.h | 14 ++-- src/lib/image/TwkFB/FastMemcpy.cpp | 6 +- src/lib/ip/IPBaseNodes/OverlayIPNode.cpp | 12 +-- src/lib/ip/IPCore/IPCore/IPNode.h | 6 +- src/lib/mu/MuQt5/qt512_to_mu.py | 57 +++++++------ src/lib/mu/MuQt5/qt515_to_mu.py | 79 +++++++++---------- src/lib/mu/MuQt6/qt68_to_mu.py | 79 +++++++++---------- src/lib/mu/MuQt6/qt6_to_mu.py | 79 +++++++++---------- .../output/AJADevices/KonaVideoDevice.cpp | 48 ++++++----- .../python/gtoContainer/gtoContainer.py | 13 +-- .../python/network/network/addSource.py | 3 +- .../python/network/network/muConsole.py | 5 +- .../python/network/network/playControl.py | 5 +- .../python/network/network/rvNetwork.py | 12 +-- src/plugins/python/rvSession/rvSession.py | 22 +++--- .../rv-packages/annot_tools/annot_tools.py | 12 +-- .../annotate_beta_color_picker.py | 2 +- .../annotate_beta/annotate_beta_engine.py | 3 +- .../annotate_beta/annotate_beta_mode.py | 6 +- .../annotate_beta/annotate_beta_paint.py | 3 +- .../annotate_beta/annotate_beta_widget.py | 6 +- .../collapse_missing_frames.py | 2 +- .../custom_lut_menu_mode.py | 17 ++-- .../custom_mattes/custom_mattes.py | 9 ++- .../data_display_indicator_mode.py | 9 +-- .../lat_long_viewer/lat_long_viewer.py | 9 +-- ...rary_environment_variable_reader_plugin.py | 10 +-- .../media_library_event_plugin.py | 6 +- .../multiple_source_media_rep.py | 25 +++--- .../multiple_source_media_rep_utils.py | 4 +- .../ocio_source_setup/ocio_source_setup.py | 33 ++++---- .../os_dependent_path_conversion_mode.py | 3 +- .../otio_reader/annotation_hook.py | 1 + .../rv-packages/otio_reader/cdlExportHook.py | 14 ++-- .../rv-packages/otio_reader/cdlHook.py | 8 +- .../rv-packages/otio_reader/cdlSchema.py | 34 +++----- .../rv-packages/otio_reader/clipHook.py | 2 +- .../rv-packages/otio_reader/effectHook.py | 11 +-- .../otio_reader/genericEffectHook.py | 2 +- .../otio_reader/multiRepPostExportHook.py | 4 +- .../rv-packages/otio_reader/otio_reader.py | 73 ++++++++--------- .../otio_reader/otio_reader_plugin.py | 15 ++-- .../rv-packages/otio_reader/otio_writer.py | 31 +++----- .../otio_reader/retimeExportHook.py | 14 ++-- .../otio_reader/sourcePostExportHook.py | 18 ++--- .../rv-packages/otio_reader/timeWarpHook.py | 4 +- src/plugins/rv-packages/pyhello/pyhello.py | 2 +- .../rv-packages/pymystuff/pymystuff.py | 3 +- .../pyside_example/pyside_example.py | 29 +++---- src/plugins/rv-packages/rvnuke/menu.py | 2 +- src/plugins/rv-packages/rvnuke/rvNetwork.py | 13 ++- src/plugins/rv-packages/rvnuke/rvNuke.py | 14 ++-- .../session_manager/local_thumbnail_gen.py | 3 +- .../rv-packages/source_setup/source_setup.py | 20 +++-- .../stereo_autoload/stereo_autoload.py | 7 +- .../stereo_disassembly/stereo_disassembly.py | 6 +- src/plugins/rv-packages/webview2/webview2.py | 24 ++---- 84 files changed, 576 insertions(+), 675 deletions(-) diff --git a/conan/scripts/export_recipes.py b/conan/scripts/export_recipes.py index 2f365d95b..cea6499d2 100644 --- a/conan/scripts/export_recipes.py +++ b/conan/scripts/export_recipes.py @@ -16,7 +16,6 @@ from pathlib import Path import yaml - from _common import CONAN_USER, conan_exec, load_packages diff --git a/conan/scripts/validate_packages_yml.py b/conan/scripts/validate_packages_yml.py index 1e2baa8e2..76668a3c8 100644 --- a/conan/scripts/validate_packages_yml.py +++ b/conan/scripts/validate_packages_yml.py @@ -11,7 +11,6 @@ import sys import yaml - from _common import PACKAGES_YML REQUIRED = {"name": str, "version": str, "channel": str, "cci_folder": str} diff --git a/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-four.md b/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-four.md index 7680c069d..34bc2373f 100644 --- a/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-four.md +++ b/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-four.md @@ -15,13 +15,13 @@ _Note: there are some slight differences that need to be noted when translating to make the commands visible in the current namespace. In Python you need to include the package name: ```python - from rv.commands import * +from rv.commands import * ``` or ```python - import rv.commands +import rv.commands ``` ### Open RV Python quickstart @@ -29,24 +29,25 @@ or In order to extend RV using Python you will be making a "mode" as part of an rvpkg package—this is identical to the way it’s done in Mu and this is the method that we use internally to add new functions to RV's interface. Creation of a modes and packages is documented later in this chapter. Here is a very simple mode written in Python which is part of the RV packages as `pyhello-1.1.rvpkg`. ```python -import rv.rvtypes +import rv.rvtypes import rv.commands -class PyHello(rv.rvtypes.MinorMode): + +class PyHello(rv.rvtypes.MinorMode): "A simple example that shows how to make shift-Z start/stop playback" - def togglePlayback(self, event): - if rv.commands.isPlaying(): - rv.commands.stop() - else: + def togglePlayback(self, event): + if rv.commands.isPlaying(): + rv.commands.stop() + else: rv.commands.play() - def __init__(self): - rv.rvtypes.MinorMode.__init__(self) - self.init("pyhello", [("key-down--Z", self.togglePlayback, "Z key")], None) + def __init__(self): + rv.rvtypes.MinorMode.__init__(self) + self.init("pyhello", [("key-down--Z", self.togglePlayback, "Z key")], None) - def createMode(): - "Required to initialize the module. RV will call this function to create your mode." + def createMode(): + "Required to initialize the module. RV will call this function to create your mode." return PyHello() ``` @@ -62,18 +63,20 @@ It's possible to call Mu code from Python, but in practice you will probably not ```python from pymu import MuSymbol + F = MuSymbol("commands.play") -F() +F() ``` If the Mu function has arguments you supply them when calling. Return values are automatically converted between languages. The conversions are indicated in Figure [4.3](#43-python-mu-type-conversions). ```python from pymu import MuSymbol + F = MuSymbol("commands.isPlaying") G = MuSymbol("commands.setWindowTitle") if F() == True: - G("PLAYING") + G("PLAYING") ``` Once a MuSymbol object has been created, the overhead to call it is minimal. All of the Mu commands module is imported on start up or reimplemented as native CPython in the Python rv.commands module so you will not need to create MuSymbol objects yourself; just import rv.commands and use the pre-existing ones. @@ -225,7 +228,7 @@ label.show() # Enter Qt application main loop. app.exec_() -sys.exit() +sys.exit() ``` To access RV's essential session window Qt QWidgets, i.e. the main window, the GL view, top tool bar and bottom tool bar, import the Python module 'rv.qtutils'. @@ -245,7 +248,7 @@ rvSessionGLView = rv.qtutils.sessionGLView() rvSessionTopToolBar = rv.qtutils.sessionTopToolBar() # Gets the current RV session bottom tool bar as a PySide QToolBar. -rvSessionBottomToolBar = rv.qtutils.sessionBottomToolBar() +rvSessionBottomToolBar = rv.qtutils.sessionBottomToolBar() ``` ### 4.5 Open RV Python Implementation FAQ diff --git a/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-two.md b/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-two.md index d38b5c72e..182aafdbd 100644 --- a/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-two.md +++ b/docs/rv-manuals/rv-reference-manual/rv-reference-manual-chapter-two.md @@ -83,6 +83,7 @@ If you need to, RV can load sources asynchronously, also known as progressive so ```python from rv import commands as rvc + rvc.setProgressiveSourceLoading(True) ``` @@ -120,7 +121,7 @@ You can expect this sequence of events: Enabling progressive source loading significantly increases the complexity of scripting. Consider the following example: ```python -rv.commands.addSource('/my/clip/1') +rv.commands.addSource("/my/clip/1") rv.commands.setFPS(60.00) ``` @@ -201,7 +202,7 @@ A full property name has three parts: the node name, the component name, and the or in Python: ```py -setFloatProperty("display.color.gamma", [2.2, 2.2, 2.2], True) +setFloatProperty("display.color.gamma", [2.2, 2.2, 2.2], True) ``` In this case the value is being set to 2.2. @@ -231,7 +232,7 @@ setFloatProperty("#RVColor.color.exposure", float[] {2.0, 2.0, 2.0}, true) or in Python: ```py -setFloatProperty("#RVColor.color.exposure", [2.0, 2.0, 2.0], True) +setFloatProperty("#RVColor.color.exposure", [2.0, 2.0, 2.0], True) ``` In sequence mode (i.e. the default case), only one RVColor node is usually active at a time (the one belonging to the source being viewed at the current frame). In stack mode, the RVColor nodes for all of the sources could be active. In that case, they will all have their exposure set. In the UI, properties are almost exclusively addressed in this manner so that making changes affects the currently visible sources only. See figure [2.9](#active-nodes-in-the-image-processing-graph) for a diagrammatic explanation. diff --git a/openrvcore-conanfile.py b/openrvcore-conanfile.py index f2be84440..d2eaed724 100644 --- a/openrvcore-conanfile.py +++ b/openrvcore-conanfile.py @@ -1,11 +1,13 @@ import os import sys -from conan import ConanFile -from conan.tools.cmake import CMake, CMakeDeps, cmake_layout, CMakeToolchain + +from conan.errors import ConanException +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv from conan.tools.gnu import PkgConfigDeps from conan.tools.microsoft import VCVars -from conan.tools.env import VirtualBuildEnv -from conan.errors import ConanException + +from conan import ConanFile # The comment below is relevant for WINDOWS only because of the usage of MSYS2. diff --git a/src/bin/apps/rv/main.cpp b/src/bin/apps/rv/main.cpp index 8b2a760fc..2a6f9e327 100644 --- a/src/bin/apps/rv/main.cpp +++ b/src/bin/apps/rv/main.cpp @@ -128,7 +128,7 @@ extern void rvThirdPartyCustomization(TwkApp::Bundle& bundle, char* licarg); // #error ********* NO VERSION INFORMATION *********** #else #ifndef _MSC_VER -#warning********* NO VERSION INFORMATION *********** +#warning ********* NO VERSION INFORMATION *********** #endif #endif #endif diff --git a/src/bin/apps/rvpkg/main.cpp b/src/bin/apps/rvpkg/main.cpp index d1795aaff..27dfb0bed 100644 --- a/src/bin/apps/rvpkg/main.cpp +++ b/src/bin/apps/rvpkg/main.cpp @@ -71,7 +71,7 @@ // #error ********* NO VERSION INFORMATION *********** #else #ifndef _MSC_VER -#warning********* NO VERSION INFORMATION *********** +#warning ********* NO VERSION INFORMATION *********** #endif #endif #endif diff --git a/src/bin/mu/mu-interp/test/rng.py b/src/bin/mu/mu-interp/test/rng.py index 02145d99e..e4d097871 100644 --- a/src/bin/mu/mu-interp/test/rng.py +++ b/src/bin/mu/mu-interp/test/rng.py @@ -19,8 +19,7 @@ def gen_random(max): def main(N): - if N < 1: - N = 1 + N = max(N, 1) gr = gen_random for i in range(1, N): gr(100.0) diff --git a/src/bin/nsapps/RV/main.cpp b/src/bin/nsapps/RV/main.cpp index c276951cc..ddab7c0aa 100644 --- a/src/bin/nsapps/RV/main.cpp +++ b/src/bin/nsapps/RV/main.cpp @@ -84,7 +84,7 @@ extern void rvThirdPartyCustomization(TwkApp::Bundle& bundle, char* licarg); #if NDEBUG // #error ********* NO VERSION INFORMATION *********** #else -#warning********* NO VERSION INFORMATION *********** +#warning ********* NO VERSION INFORMATION *********** #endif #endif diff --git a/src/bin/python/py-interp/tests/test_SSL.py b/src/bin/python/py-interp/tests/test_SSL.py index fb5a774ed..804b68a3d 100755 --- a/src/bin/python/py-interp/tests/test_SSL.py +++ b/src/bin/python/py-interp/tests/test_SSL.py @@ -24,8 +24,7 @@ def _fetch(name, func, url): def fetch_httplib(url): def impl(url): - from six.moves import http_client - from six.moves import urllib_parse + from six.moves import http_client, urllib_parse u = urllib_parse.urlparse(url) http_client.HTTPSConnection(u.netloc).request("GET", u.path) @@ -57,19 +56,19 @@ def impl(url): def fetch_pyside(url): def impl(url): try: - from PySide2.QtCore import QEventLoop, QUrl, QCoreApplication + from PySide2.QtCore import QCoreApplication, QEventLoop, QUrl from PySide2.QtNetwork import ( - QNetworkRequest, - QNetworkReply, QNetworkAccessManager, + QNetworkReply, + QNetworkRequest, ) except ImportError: try: - from PySide6.QtCore import QEventLoop, QUrl, QCoreApplication + from PySide6.QtCore import QCoreApplication, QEventLoop, QUrl from PySide6.QtNetwork import ( - QNetworkRequest, - QNetworkReply, QNetworkAccessManager, + QNetworkReply, + QNetworkRequest, ) except ImportError: pass diff --git a/src/build/install_all_rvpkg.py b/src/build/install_all_rvpkg.py index 978de7848..148d3cfb4 100644 --- a/src/build/install_all_rvpkg.py +++ b/src/build/install_all_rvpkg.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- import argparse import pathlib import subprocess diff --git a/src/build/make_openssl.py b/src/build/make_openssl.py index 32adc5ed4..343448f5f 100644 --- a/src/build/make_openssl.py +++ b/src/build/make_openssl.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # ***************************************************************************** # Copyright 2020 Autodesk, Inc. All rights reserved. @@ -12,12 +11,11 @@ import glob import os import pathlib +import platform import shutil import subprocess -import platform import tempfile import uuid -from typing import List SOURCE_DIR = "" OUTPUT_DIR = "" @@ -26,7 +24,7 @@ LIB_DIR = "" -def get_openssl_args(root) -> List[str]: +def get_openssl_args(root) -> list[str]: """ Return the path to the openssl binary given a package root. diff --git a/src/build/make_pyside.py b/src/build/make_pyside.py index 132b9a199..e39baf5b8 100755 --- a/src/build/make_pyside.py +++ b/src/build/make_pyside.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # ***************************************************************************** # Copyright 2020 Autodesk, Inc. All rights reserved. @@ -11,21 +10,21 @@ import argparse import glob import os -import re import pathlib +import platform +import re import shutil import subprocess -import platform import tempfile import uuid +from make_python import get_python_interpreter_args from utils import ( download_file, extract_7z_archive, - verify_7z_archive, update_env_path, + verify_7z_archive, ) -from make_python import get_python_interpreter_args SOURCE_DIR = "" OUTPUT_DIR = "" @@ -147,15 +146,14 @@ def prepare() -> None: os.remove(old_cmakelist_path) os.rename(cmakelist_path, old_cmakelist_path) - with open(old_cmakelist_path) as old_cmakelist: - with open(cmakelist_path, "w") as cmakelist: - for line in old_cmakelist: - new_line = line.replace( - " set(HAS_LIBXSLT 1)", - " #set(HAS_LIBXSLT 1)", - ) - - cmakelist.write(new_line) + with open(old_cmakelist_path) as old_cmakelist, open(cmakelist_path, "w") as cmakelist: + for line in old_cmakelist: + new_line = line.replace( + " set(HAS_LIBXSLT 1)", + " #set(HAS_LIBXSLT 1)", + ) + + cmakelist.write(new_line) def remove_broken_shortcuts(python_home: str) -> None: diff --git a/src/build/make_pyside6.py b/src/build/make_pyside6.py index addc003c2..0d01245d2 100755 --- a/src/build/make_pyside6.py +++ b/src/build/make_pyside6.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # ***************************************************************************** # Copyright 2024 Autodesk, Inc. All rights reserved. @@ -11,21 +10,21 @@ import argparse import glob import os -import re import pathlib +import platform +import re import shutil import subprocess -import platform import tempfile import uuid +from make_python import get_python_interpreter_args from utils import ( download_file, extract_7z_archive, - verify_7z_archive, update_env_path, + verify_7z_archive, ) -from make_python import get_python_interpreter_args SOURCE_DIR = "" OUTPUT_DIR = "" @@ -193,15 +192,14 @@ def get_fallback_clang_filename_suffix(version): os.remove(old_cmakelist_path) os.rename(cmakelist_path, old_cmakelist_path) - with open(old_cmakelist_path) as old_cmakelist: - with open(cmakelist_path, "w") as cmakelist: - for line in old_cmakelist: - new_line = line.replace( - " set(HAS_LIBXSLT 1)", - " #set(HAS_LIBXSLT 1)", - ) - - cmakelist.write(new_line) + with open(old_cmakelist_path) as old_cmakelist, open(cmakelist_path, "w") as cmakelist: + for line in old_cmakelist: + new_line = line.replace( + " set(HAS_LIBXSLT 1)", + " #set(HAS_LIBXSLT 1)", + ) + + cmakelist.write(new_line) # PySide6/shiboken6's generated bindings trigger thousands of # -Wcast-function-type-mismatch warnings from the intentional PyMethodDef diff --git a/src/build/make_python.py b/src/build/make_python.py index 8b327414a..8e4165ece 100755 --- a/src/build/make_python.py +++ b/src/build/make_python.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # ***************************************************************************** # Copyright 2020 Autodesk, Inc. All rights reserved. @@ -13,12 +12,10 @@ import glob import os import pathlib +import platform import shutil -import sys import subprocess -import platform - -from typing import List +import sys ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(ROOT_DIR) @@ -44,7 +41,7 @@ def get_sitecustomize_content() -> str: return f.read() -def get_python_interpreter_args(python_home: str, variant: str) -> List[str]: +def get_python_interpreter_args(python_home: str, variant: str) -> list[str]: """ Return the path to the python interpreter given a Python home @@ -299,28 +296,27 @@ def configure() -> None: makefile_path = os.path.join(SOURCE_DIR, "Makefile") old_makefile_path = os.path.join(SOURCE_DIR, "Makefile.old") os.rename(makefile_path, old_makefile_path) - with open(old_makefile_path) as old_makefile: - with open(makefile_path, "w") as makefile: - for line in old_makefile: - new_line = line.replace( - "-Wl,-install_name,$(prefix)/lib/libpython$(", - "-Wl,-install_name,@rpath/libpython$(", - ) - - # Adjust RPaths - if new_line.startswith("LINKFORSHARED="): - if platform.system() == "Linux": - makefile.write( - new_line.strip() + " -Wl,-rpath,'$$ORIGIN/../lib',-rpath,'$$ORIGIN/../Qt'" + "\n" - ) - elif platform.system() == "Darwin": - makefile.write( - new_line.strip() - + " -Wl,-rpath,@executable_path/../lib,-rpath,@executable_path/../Qt" - + "\n" - ) - else: - makefile.write(new_line) + with open(old_makefile_path) as old_makefile, open(makefile_path, "w") as makefile: + for line in old_makefile: + new_line = line.replace( + "-Wl,-install_name,$(prefix)/lib/libpython$(", + "-Wl,-install_name,@rpath/libpython$(", + ) + + # Adjust RPaths + if new_line.startswith("LINKFORSHARED="): + if platform.system() == "Linux": + makefile.write( + new_line.strip() + " -Wl,-rpath,'$$ORIGIN/../lib',-rpath,'$$ORIGIN/../Qt'" + "\n" + ) + elif platform.system() == "Darwin": + makefile.write( + new_line.strip() + + " -Wl,-rpath,@executable_path/../lib,-rpath,@executable_path/../Qt" + + "\n" + ) + else: + makefile.write(new_line) def build() -> None: diff --git a/src/build/patch_OCIO/ocio_pyopencolorio_patch.py b/src/build/patch_OCIO/ocio_pyopencolorio_patch.py index 7a547ed6a..2a1cd5e62 100644 --- a/src/build/patch_OCIO/ocio_pyopencolorio_patch.py +++ b/src/build/patch_OCIO/ocio_pyopencolorio_patch.py @@ -1,25 +1,24 @@ import argparse -import shutil import pathlib import re +import shutil def patch_execute(filename): did_find_match = False backup_cmakelist_path = f"{filename}.bk" shutil.copyfile(filename, backup_cmakelist_path) - with open(backup_cmakelist_path, "r") as backup_cmakelist: - with open(filename, "w") as cmakelist: - for line in backup_cmakelist: - if re.match(r"^\s*set.*_PublicLibs", line, re.IGNORECASE): - new_line = line.replace( - "set(_PublicLibs ${Python_LIBRARIES})", - "set(_PublicLibs ${RV_Python_LIBRARIES})", - ) - cmakelist.write(new_line) - did_find_match = True - else: - cmakelist.write(line) + with open(backup_cmakelist_path, "r") as backup_cmakelist, open(filename, "w") as cmakelist: + for line in backup_cmakelist: + if re.match(r"^\s*set.*_PublicLibs", line, re.IGNORECASE): + new_line = line.replace( + "set(_PublicLibs ${Python_LIBRARIES})", + "set(_PublicLibs ${RV_Python_LIBRARIES})", + ) + cmakelist.write(new_line) + did_find_match = True + else: + cmakelist.write(line) if not did_find_match: raise Exception(f"File {filename} doesn't contain _PublicLibs. Cannot patch") diff --git a/src/build/patch_PySide2/windows_desktop.py b/src/build/patch_PySide2/windows_desktop.py index ac6d64dfe..0cf9d2164 100644 --- a/src/build/patch_PySide2/windows_desktop.py +++ b/src/build/patch_PySide2/windows_desktop.py @@ -4,16 +4,14 @@ # SPDX-License-Identifier: Apache-2.0 # +import fnmatch import functools import os import sys -import fnmatch from ..config import config from ..options import OPTION -from ..utils import copydir, copyfile, makefile -from ..utils import regenerate_qt_resources, filter_match -from ..utils import download_and_extract_7z +from ..utils import copydir, copyfile, download_and_extract_7z, filter_match, makefile, regenerate_qt_resources def prepare_packages_win32(self, vars): @@ -392,7 +390,7 @@ def qt_build_config_filter(patterns, file_name, file_full_path): # e.g. "/home/work/qt/qtbase/bin" file_path_dir_name = os.path.dirname(file_full_path) # e.g. "Qt5Coredd" - maybe_debug_name = "{}d".format(file_base_name) + maybe_debug_name = f"{file_base_name}d" if self.debug or OPTION["DEBUG"]: filter = debug diff --git a/src/build/remove_absolute_rpath.py b/src/build/remove_absolute_rpath.py index a34e7062c..f27a3088c 100755 --- a/src/build/remove_absolute_rpath.py +++ b/src/build/remove_absolute_rpath.py @@ -12,10 +12,9 @@ import logging import os import pathlib -from pathlib import Path import subprocess import threading - +from pathlib import Path future_lock = threading.Lock() diff --git a/src/build/sitecustomize.py b/src/build/sitecustomize.py index 431ebd3a6..5479f988c 100644 --- a/src/build/sitecustomize.py +++ b/src/build/sitecustomize.py @@ -14,9 +14,9 @@ all the certificate authorities that are distributed with Firefox. """ +import os import site import sys -import os try: import certifi diff --git a/src/build/test_python_distribution.py b/src/build/test_python_distribution.py index 4fa78bf28..4f93aff69 100644 --- a/src/build/test_python_distribution.py +++ b/src/build/test_python_distribution.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # ***************************************************************************** # Copyright 2020 Autodesk, Inc. All rights reserved. # diff --git a/src/build/test_python_imports.py b/src/build/test_python_imports.py index 966d34756..21e4fd5f1 100644 --- a/src/build/test_python_imports.py +++ b/src/build/test_python_imports.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # ***************************************************************************** # Copyright 2025 Autodesk, Inc. All rights reserved. diff --git a/src/build/utils.py b/src/build/utils.py index 751f85437..4857017a7 100644 --- a/src/build/utils.py +++ b/src/build/utils.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # ***************************************************************************** # Copyright 2020 Autodesk, Inc. All rights reserved. # @@ -10,14 +8,13 @@ import itertools import os import platform -import requests import shutil import subprocess import sys +from zipfile import ZipFile +import requests from py7zr import SevenZipFile, exceptions -from typing import List -from zipfile import ZipFile def _windows_zip_impl(input_folder: str, output_zip: str) -> None: @@ -301,7 +298,7 @@ def get_environment_from_batch_command(env_cmd, initial=None): def validate_pair(ob): try: if not (len(ob) == 2): - print("Unexpected result: {}".format(ob)) + print(f"Unexpected result: {ob}") raise ValueError except Exception: return False @@ -321,7 +318,7 @@ def consume(iter): # create a tag so we can tell in the output when the proc is done tag = "Done running command" # construct a cmd.exe command to do accomplish this - cmd = 'cmd.exe /E:ON /V:ON /s /c "{} && echo "{}" && set"'.format(env_cmd, tag) + cmd = f'cmd.exe /E:ON /V:ON /s /c "{env_cmd} && echo "{tag}" && set"' # launch the process proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=initial) # parse the output sent to stdout @@ -412,7 +409,7 @@ def get_mingw64_path_on_windows(winpath: str) -> str: ) -def get_mingw64_args(cmd_args: List[str]) -> List[str]: +def get_mingw64_args(cmd_args: list[str]) -> list[str]: updated_cmd_args = cmd_args updated_cmd_args.append(";sleep 10") diff --git a/src/lib/app/RvCommon/generate_theme.py b/src/lib/app/RvCommon/generate_theme.py index 98143b22c..707fc460d 100755 --- a/src/lib/app/RvCommon/generate_theme.py +++ b/src/lib/app/RvCommon/generate_theme.py @@ -34,13 +34,12 @@ python generate_theme.py --output rv_custom.qss --set PRIMARY_BACKGROUND=rgb(40,40,40) """ -import sys -import os import argparse -import platform import logging +import os +import platform import re -from typing import Dict, List, Optional, Set, Tuple +import sys # Setup logging @@ -99,7 +98,7 @@ def adjust_output_path(output_file: str) -> str: return output_file -def adjust_config_path(config_file: Optional[str]) -> Optional[str]: +def adjust_config_path(config_file: str | None) -> str | None: """Adjust config file path to RvCommon directory if running from OpenRV root""" if not config_file: return config_file @@ -124,9 +123,9 @@ def adjust_config_path(config_file: Optional[str]) -> Optional[str]: return config_file -def load_variables_from_config(config_file: Optional[str]) -> Dict[str, str]: +def load_variables_from_config(config_file: str | None) -> dict[str, str]: """Load variables from a config file with validation""" - variables: Dict[str, str] = {} + variables: dict[str, str] = {} invalid_count: int = 0 if not config_file or not os.path.exists(config_file): @@ -196,7 +195,7 @@ def validate_css_value(var_name: str, value: str) -> bool: return True # Color-related variables should be valid CSS colors - color_vars: Set[str] = { + color_vars: set[str] = { "PRIMARY_BACKGROUND", "SECONDARY_BACKGROUND", "TERTIARY_BACKGROUND", @@ -232,7 +231,7 @@ def validate_css_value(var_name: str, value: str) -> bool: return 0 <= r <= 255 and 0 <= g <= 255 and 0 <= b <= 255 # Named colors (basic validation) - named_colors: Set[str] = { + named_colors: set[str] = { "black", "white", "red", @@ -264,7 +263,7 @@ def validate_css_value(var_name: str, value: str) -> bool: def get_example_value(var_name: str) -> str: """Get example values for variables to help users""" - examples: Dict[str, str] = { + examples: dict[str, str] = { "PRIMARY_BACKGROUND": "rgb(34,34,34)", "ACCENT_PRIMARY": "rgb(7,75,120)", "TEXT_PRIMARY": "rgb(200,200,200)", @@ -274,7 +273,7 @@ def get_example_value(var_name: str) -> str: return examples.get(var_name, "rgb(100,100,100)") -def collect_missing_variables(missing_vars: Set[str]) -> Dict[str, str]: +def collect_missing_variables(missing_vars: set[str]) -> dict[str, str]: """Interactive collection of missing variables with validation""" print("\nMissing variables detected. Please provide values:") print("('quit' to abort, 'default' to use default value, 'help' for examples, Ctrl+C to cancel)") @@ -283,7 +282,7 @@ def collect_missing_variables(missing_vars: Set[str]) -> Dict[str, str]: config_file = adjust_config_path("rv_theme_variables.conf") variables = load_variables_from_config(config_file) - collected_vars: Dict[str, str] = {} + collected_vars: dict[str, str] = {} try: for var_name in sorted(missing_vars): while True: @@ -336,7 +335,7 @@ def collect_missing_variables(missing_vars: Set[str]) -> Dict[str, str]: return collected_vars -def process_template(template_file: str, variables: Dict[str, str]) -> str: +def process_template(template_file: str, variables: dict[str, str]) -> str: """Process template file replacing {{variable}} placeholders""" if not os.path.exists(template_file): raise FileNotFoundError(f"Template file '{template_file}' not found") @@ -386,7 +385,7 @@ def process_template(template_file: str, variables: Dict[str, str]) -> str: return content -def parse_variable_override(var_string: str) -> Tuple[str, str]: +def parse_variable_override(var_string: str) -> tuple[str, str]: """Parse a variable override in format KEY=VALUE""" if "=" not in var_string: raise ValueError(f"Invalid variable format: {var_string}. Use KEY=VALUE") @@ -395,9 +394,9 @@ def parse_variable_override(var_string: str) -> Tuple[str, str]: def generate_theme( - config_file: Optional[str], + config_file: str | None, output_file: str, - variable_overrides: Optional[List[str]] = None, + variable_overrides: list[str] | None = None, ) -> str: """Generate a theme file""" logger.info(f"Generating theme: {output_file}") diff --git a/src/lib/app/TwkMediaLibrary/TwkMediaLibrary/Library.h b/src/lib/app/TwkMediaLibrary/TwkMediaLibrary/Library.h index a1bffc5fb..a41d219b0 100644 --- a/src/lib/app/TwkMediaLibrary/TwkMediaLibrary/Library.h +++ b/src/lib/app/TwkMediaLibrary/TwkMediaLibrary/Library.h @@ -144,8 +144,8 @@ namespace TwkMediaLibrary RawExportCapabilityFlag = 1 << 3, // can export raw media files EditCapabilityFlag = 1 << 4, // can edit library - DefaultCapabiliesFlag = - AdministratorCapabilityFlag | NoWatermarkCapabilityFlag | ExportCapabilityFlag | RawExportCapabilityFlag | EditCapabilityFlag + DefaultCapabiliesFlag = AdministratorCapabilityFlag | NoWatermarkCapabilityFlag | ExportCapabilityFlag | RawExportCapabilityFlag + | EditCapabilityFlag }; enum TaskType diff --git a/src/lib/app/py_rvui/rv/qtutils.py b/src/lib/app/py_rvui/rv/qtutils.py index ec72da90c..d71440fd9 100644 --- a/src/lib/app/py_rvui/rv/qtutils.py +++ b/src/lib/app/py_rvui/rv/qtutils.py @@ -9,15 +9,13 @@ from PySide2 import QtGui, QtWidgets from PySide2.QtGui import * from PySide2.QtWidgets import * - from shiboken2 import wrapInstance - from shiboken2 import getCppPointer + from shiboken2 import getCppPointer, wrapInstance except ImportError: try: from PySide6 import QtGui, QtWidgets from PySide6.QtGui import * from PySide6.QtWidgets import * - from shiboken6 import wrapInstance - from shiboken6 import getCppPointer + from shiboken6 import getCppPointer, wrapInstance except ImportError: pass diff --git a/src/lib/app/py_rvui/rv/rvtypes.py b/src/lib/app/py_rvui/rv/rvtypes.py index f423562ab..cf6baa885 100644 --- a/src/lib/app/py_rvui/rv/rvtypes.py +++ b/src/lib/app/py_rvui/rv/rvtypes.py @@ -3,10 +3,11 @@ # # SPDX-License-Identifier: Apache-2.0 # -import rv.commands +import math import os import sys -import math + +import rv.commands def concat_seperator(): @@ -26,7 +27,7 @@ def __init__(self): self.minorModes = [] -class Mode(object): +class Mode: """A mode is a feature unit. It comes in two varieties: major and minor. The mode can be declared in its own file and provide key bindings, a menu, multiple event tables if needed, a render function, and is @@ -57,12 +58,10 @@ def drawOnPresentation(self): def activate(self): "Called right after activation" self._active = True - pass def deactivate(self): "Called right before deactivation" self._active = False - pass def toggle(self): self._active = not self._active @@ -79,11 +78,9 @@ def toggle(self): def layout(self, event): "Layout any margins or precompute anything necessary for rendering" - pass def render(self, event): "The render function is called on each active minor mode." - pass def supportPath(self, module, packageName=None): if packageName is None: diff --git a/src/lib/app/py_rvui/rv_commands_setup.py b/src/lib/app/py_rvui/rv_commands_setup.py index 6dd2843af..9fa206abd 100644 --- a/src/lib/app/py_rvui/rv_commands_setup.py +++ b/src/lib/app/py_rvui/rv_commands_setup.py @@ -5,6 +5,7 @@ # import os import sys + import rv.commands import rv.extra_commands import rv.runtime diff --git a/src/lib/geometry/TwkContainer/TwkContainer/Properties.h b/src/lib/geometry/TwkContainer/TwkContainer/Properties.h index f4ba77d45..91968221b 100644 --- a/src/lib/geometry/TwkContainer/TwkContainer/Properties.h +++ b/src/lib/geometry/TwkContainer/TwkContainer/Properties.h @@ -42,13 +42,13 @@ namespace TwkContainer // }; // #define PROPERTY_TRAITS(PTYPENAME, TYPE, TYPENAME, LAYOUT, WIDTH) \ -// template <> const char* PropertyTraits::typeName(); \ -// template <> Property::Layout PropertyTraits::layout(); \ -// template <> size_t PropertyTraits::xsize(); \ -// template <> size_t PropertyTraits::ysize(); \ -// template <> size_t PropertyTraits::zsize(); \ -// typedef TypedProperty::Container, \ -// WIDTH, 0, 0, Property::LAYOUT> PTYPENAME; + // template <> const char* PropertyTraits::typeName(); \ + // template <> Property::Layout PropertyTraits::layout(); \ + // template <> size_t PropertyTraits::xsize(); \ + // template <> size_t PropertyTraits::ysize(); \ + // template <> size_t PropertyTraits::zsize(); \ + // typedef TypedProperty::Container, \ + // WIDTH, 0, 0, Property::LAYOUT> PTYPENAME; #define PROPERTY_TRAITS(PTYPENAME, TYPE, TYPENAME, LAYOUT, WIDTH) \ typedef TypedProperty, WIDTH, 0, 0, 0, Property::LAYOUT> PTYPENAME; diff --git a/src/lib/image/TwkFB/FastMemcpy.cpp b/src/lib/image/TwkFB/FastMemcpy.cpp index 40f0a5d58..900ad31fe 100644 --- a/src/lib/image/TwkFB/FastMemcpy.cpp +++ b/src/lib/image/TwkFB/FastMemcpy.cpp @@ -93,8 +93,8 @@ void* FastMemcpy_SIMD(void* PXLRESTRICT outBuf, const void* PXLRESTRICT inBuf, s return small_memcpy(outBuf, inBuf, n); } - const unsigned char* PXLRESTRICT src = static_cast(inBuf); - unsigned char* PXLRESTRICT dst = static_cast(outBuf); + const unsigned char* PXLRESTRICT src = static_cast(inBuf); + unsigned char* PXLRESTRICT dst = static_cast(outBuf); // memcpy until dst is aligned with simd if (!is_aligned(dst, SSE_REGISTER_SIZE)) @@ -114,7 +114,7 @@ void* FastMemcpy_SIMD(void* PXLRESTRICT outBuf, const void* PXLRESTRICT inBuf, s { for (; n >= step; n -= step) { - _mm_prefetch(reinterpret_cast(src) + 1024, _MM_HINT_T0); + _mm_prefetch(reinterpret_cast(src) + 1024, _MM_HINT_T0); __m128 xmm0 = _mm_load_ps((float*)(src + 0 * SSE_REGISTER_SIZE)); __m128 xmm1 = _mm_load_ps((float*)(src + 1 * SSE_REGISTER_SIZE)); __m128 xmm2 = _mm_load_ps((float*)(src + 2 * SSE_REGISTER_SIZE)); diff --git a/src/lib/ip/IPBaseNodes/OverlayIPNode.cpp b/src/lib/ip/IPBaseNodes/OverlayIPNode.cpp index b15caa965..463615afc 100644 --- a/src/lib/ip/IPBaseNodes/OverlayIPNode.cpp +++ b/src/lib/ip/IPBaseNodes/OverlayIPNode.cpp @@ -710,23 +710,23 @@ namespace IPCore // leftMatteWidth widthVisible rightMatteWidth // ____/\_____ ___________/\____________ ____/\_____ // / \/ \/ \ - // ------------------------[0.5]------------------------ + // ------------------------[0.5]------------------------ // | |\ - // | topMatte (m_top) | } + // | topMatte (m_top) | } // topMatteHeight // |(leftSideOfImage,topMatteVPosition) |/ // *---------------------------------------------------| // | | | |\ - // | | | | \ - // | leftMatte | Visible Image | rightMatte | \ - // | (m_left) | | (m_right) | } + // | | | | \ + // | leftMatte | Visible Image | rightMatte | \ + // | (m_left) | | (m_right) | } // heightVisible | | | | / | | // | | / // |(leftSideOfImage,sideMattesVPosition) // |(rightMatteHPosition,sideMattesVPosition) // *--------------------------------------*------------| // | |\ - // | bottomMatte (m_bottom) | } + // | bottomMatte (m_bottom) | } // bottomMatteHeight // |(leftSideOfImage,-0.5) |/ // *----------------------[-0.5]------------------------ diff --git a/src/lib/ip/IPCore/IPCore/IPNode.h b/src/lib/ip/IPCore/IPCore/IPNode.h index c1dc7e2c6..8ed02e900 100644 --- a/src/lib/ip/IPCore/IPCore/IPNode.h +++ b/src/lib/ip/IPCore/IPCore/IPNode.h @@ -139,8 +139,8 @@ namespace IPCore CacheThreadMarker = (1 << 8), CacheEvalThread = (1 << 9), - DisplayThread = - DisplayNoEvalThread | DisplayEvalThread | DisplayPassThroughThread | DisplayMaybeEvalThread | DisplayCacheEvalThread + DisplayThread = DisplayNoEvalThread | DisplayEvalThread | DisplayPassThroughThread | DisplayMaybeEvalThread + | DisplayCacheEvalThread }; // @@ -168,7 +168,7 @@ namespace IPCore // same event propagation behaviour then RV 7.6 LegacyPropagateTarget = GroupPropagateTarget | GraphPropagateTarget | OutputPropagateTarget | MemberPropagateTarget - | GroupAndGraphInOutputPropagateTarget, + | GroupAndGraphInOutputPropagateTarget, // new fast event propagation behaviour // we avoid to propagate in graph and group after an output is diff --git a/src/lib/mu/MuQt5/qt512_to_mu.py b/src/lib/mu/MuQt5/qt512_to_mu.py index 8c32fe112..ef615a5ec 100755 --- a/src/lib/mu/MuQt5/qt512_to_mu.py +++ b/src/lib/mu/MuQt5/qt512_to_mu.py @@ -4,15 +4,16 @@ # # SPDX-License-Identifier: Apache-2.0 # -from sgmllib import SGMLParser -import urllib -import sys -import traceback +import os +import pickle import pprint -import string import re -import pickle -import os +import string +import sys +import traceback +import urllib + +from sgmllib import SGMLParser # # Qt 5 splits the docs into subdirs which complicates things slightly. @@ -869,7 +870,7 @@ def constReferenceType(t): def indexOf(element, sequence): - for i in range(0, len(sequence)): + for i in range(len(sequence)): if element == sequence[i]: return i return -1 @@ -1646,7 +1647,7 @@ def parseFunction(func, qtnamespace): params.append(parseParameter(current, count)) # make new name for params with same name as func - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] if p[0] == nameproto[-1]: params[i] = (p[0] + "_", p[1], p[2]) @@ -1791,7 +1792,7 @@ def fullEnumName(self, name): return None def finish(self): - for q in range(0, len(self.functions)): + for q in range(len(self.functions)): f = self.functions[q] (name, fconst, params, rtype, prop) = f ctype = self.name + "::" + rtype @@ -1807,7 +1808,7 @@ def finish(self): (name, fconst, params, rtype, prop) = self.functions[q] - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p ctype = self.name + "::" + ptype @@ -2000,7 +2001,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): fargs = len(f.args) if fargs == nargs and not f.failed: samecount = 0 - for i in range(0, nargs): + for i in range(nargs): a = f.args[i][1] b = self.args[i][1] if a.startswith("flags"): @@ -2236,7 +2237,7 @@ def compiledFunction(self): # else: expr = "%s::%s(" % (muclass.qt.name, callname) - for i in range(0, len(self.args)): + for i in range(len(self.args)): a = self.args[i] (aname, atype, aval) = a (dexpr, dtype) = self.derefArg(a) @@ -2639,7 +2640,7 @@ def assembleIncludes(self, cpplines): itypes = set([]) endinclude = 0 - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): m = makeRE.search(cpplines[i]) if "#include" in cpplines[i]: endinclude = i @@ -2807,7 +2808,7 @@ def outputMuQtNativeImplementation(self): out += rtype_clean + " MuQt_" + self.name + "::" + name + "(" # args - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -2819,7 +2820,7 @@ def outputMuQtNativeImplementation(self): if f.isconstructor: # call the base class constr out += "\n : " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -2858,7 +2859,7 @@ def outputMuQtNativeImplementation(self): else: out += "return " out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -2876,7 +2877,7 @@ def outputMuQtNativeImplementation(self): # if f.name == "splitPath": # print str(parms) out += " args[0] = Value(Pointer(_obj));\n" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # print str(f.args[i+1]) out += " args[%d] = Value(%s);\n" % ( @@ -2895,7 +2896,7 @@ def outputMuQtNativeImplementation(self): out += "defaultValue<%s>();\n" % rtype_clean else: out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -2939,7 +2940,7 @@ def outputMuQtNativeDeclaration(self): out += " " + "MuQt_" + name + "(Pointer muobj, const CallEnvironment*" else: out += " " + rtype + " " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -2960,7 +2961,7 @@ def outputMuQtNativeDeclaration(self): if parent: nameSuffix = "_parent" out += " " + nvrtype + " " + name + "_pub%s(" % nameSuffix - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if "::" in ptype: @@ -2975,7 +2976,7 @@ def outputMuQtNativeDeclaration(self): if parent: out += self.name + "::" out += name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3071,7 +3072,7 @@ def outputSourceFiles(self): elif line.find("{%%propExclusions%%}") != -1: if len(self.demotedProps): s = " const char* propExclusions[] = {" - for i in range(0, len(self.demotedProps)): + for i in range(len(self.demotedProps)): if i != 0: s += ", " s += '"%s"' % self.demotedProps[i][0] @@ -3096,7 +3097,7 @@ def outputSourceFiles(self): cpplines.append(string.replace(line, "$T", self.name)) cppfile.close() - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): line = cpplines[i] if len(line) >= 1 and line[-1] != "\n": cpplines[i] = line + "\n" @@ -3180,7 +3181,7 @@ def outputModuleDefinition(self, finishedMap): self.name, self.name, ) - for i in range(0, len(inherits)): + for i in range(len(inherits)): out += ", t_%s" % inherits[i].name out += ");" else: @@ -3460,9 +3461,7 @@ def handle_data(self, data): return elif data == "Obsolete flags:": # note obsolete self.defenum = False - elif data == " (preliminary)": # shows up in qwidget.html, messes up everything - return - elif data == " (deprecated)": # shows up in qprocess.html, messes up everything + elif data == " (preliminary)" or data == " (deprecated)": # shows up in qwidget.html, messes up everything return elif self.modulespan and "Q" in data: self.module = data @@ -3656,7 +3655,7 @@ def recursiveParse(url): for u in parser.childurls: # if "qwidget.html" in u: recursiveParse(u) - except IOError: + except OSError: print("FAILED: (IOError)", url) except Exception: print("FAILED:", url) diff --git a/src/lib/mu/MuQt5/qt515_to_mu.py b/src/lib/mu/MuQt5/qt515_to_mu.py index 7b28ab9e0..d8c416af6 100755 --- a/src/lib/mu/MuQt5/qt515_to_mu.py +++ b/src/lib/mu/MuQt5/qt515_to_mu.py @@ -4,15 +4,16 @@ # # SPDX-License-Identifier: Apache-2.0 # -from sgmllib import SGMLParser -import urllib -import sys -import traceback +import os +import pickle import pprint -import string import re -import pickle -import os +import string +import sys +import traceback +import urllib + +from sgmllib import SGMLParser # # Qt 5 splits the docs into subdirs which complicates things slightly. @@ -816,7 +817,7 @@ def constReferenceType(t): def indexOf(element, sequence): - for i in range(0, len(sequence)): + for i in range(len(sequence)): if element == sequence[i]: return i return -1 @@ -1956,7 +1957,7 @@ def parseFunction(func, qtnamespace): message("Params: " + str(params)) # make new name for params with same name as func - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # Compare the first element of p and the last element of nameproto. message("Before comparison: " + str(p) + " with " + str(nameproto)) @@ -1982,7 +1983,7 @@ def parseFunction(func, qtnamespace): message("WARNING: Nameproto empty for " + func) except Exception: # Skip any function that has issue with the simple parsing above. - print("Error parsing function.. skipping: {0}".format(orig_func)) + print(f"Error parsing function.. skipping: {orig_func}") return None return None @@ -2118,7 +2119,7 @@ def fullEnumName(self, name): return None def finish(self): - for q in range(0, len(self.functions)): + for q in range(len(self.functions)): f = self.functions[q] (name, fconst, params, rtype, prop) = f ctype = self.name + "::" + rtype @@ -2134,7 +2135,7 @@ def finish(self): (name, fconst, params, rtype, prop) = self.functions[q] - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p ctype = self.name + "::" + ptype @@ -2268,12 +2269,8 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): self.isconst = "const" in const self.purevirtual = "= 0" in qtfunc[1] - print("Processing function {0}".format(qtfunc)) - print( - "failed: {0}, isprop: {1}, isprotected: {2}".format( - str(self.failed), str(self.isprop), str(self.isprotected) - ) - ) + print(f"Processing function {qtfunc}") + print(f"failed: {self.failed!s}, isprop: {self.isprop!s}, isprotected: {self.isprotected!s}") if self.operator: self.name = name[8 : len(name)] @@ -2345,7 +2342,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): fargs = len(f.args) if fargs == nargs and not f.failed: samecount = 0 - for i in range(0, nargs): + for i in range(nargs): a = f.args[i][1] b = self.args[i][1] if a.startswith("flags"): @@ -2367,7 +2364,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): for a in self.args: self.compiled += "_%s" % mangleName(conditionType(a[1])) - print("self.compiled={0}, {1}".format(self.compiled, self.failed)) + print(f"self.compiled={self.compiled}, {self.failed}") def unpackReturnValue(self, expr): rtype = conditionType(self.rtype) @@ -2418,7 +2415,7 @@ def symbolDeclaration(self): return out def nodeImplementation(self): - print("nodeImplementation -> {0}".format(self.name)) + print(f"nodeImplementation -> {self.name}") if self.failed: return "// MISSING NODE: %s" % self.muDeclaration() if self.abstract and self.isconstructor and not self.muclass.inheritable: @@ -2487,7 +2484,7 @@ def compiledFunction(self): else: print("FAILED to find", self.rtype) - print("Compiled function for {0}".format(muclass.name)) + print(f"Compiled function for {muclass.name}") isQObject = muclass.isAByName("QObject") isQPaintDevice = muclass.isAByName("QPaintDevice") @@ -2592,7 +2589,7 @@ def compiledFunction(self): # else: expr = "%s::%s(" % (muclass.qt.name, callname) - for i in range(0, len(self.args)): + for i in range(len(self.args)): a = self.args[i] (aname, atype, aval) = a (dexpr, dtype) = self.derefArg(a) @@ -2964,7 +2961,7 @@ def outputCompiledNodes(self): def outputNodeImplementations(self): out = "" - print("self.statics for {0}".format(self.name)) + print(f"self.statics for {self.name}") for f in filter(self.F_trans, self.functions + self.statics + self.castoperators): out += f.nodeImplementation() @@ -3003,7 +3000,7 @@ def assembleIncludes(self, cpplines): itypes = set([]) endinclude = 0 - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): m = makeRE.search(cpplines[i]) if "#include" in cpplines[i]: endinclude = i @@ -3171,7 +3168,7 @@ def outputMuQtNativeImplementation(self): out += rtype_clean + " MuQt_" + self.name + "::" + name + "(" # args - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3183,7 +3180,7 @@ def outputMuQtNativeImplementation(self): if f.isconstructor: # call the base class constr out += "\n : " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3222,7 +3219,7 @@ def outputMuQtNativeImplementation(self): else: out += "return " out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3240,7 +3237,7 @@ def outputMuQtNativeImplementation(self): # if f.name == "splitPath": # print str(parms) out += " args[0] = Value(Pointer(_obj));\n" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # print str(f.args[i+1]) out += " args[%d] = Value(%s);\n" % ( @@ -3259,7 +3256,7 @@ def outputMuQtNativeImplementation(self): out += "defaultValue<%s>();\n" % rtype_clean else: out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3305,7 +3302,7 @@ def outputMuQtNativeDeclaration(self): out += " " + "MuQt_" + name + "(Pointer muobj, const CallEnvironment*" else: out += " " + rtype + " " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3326,7 +3323,7 @@ def outputMuQtNativeDeclaration(self): if parent: nameSuffix = "_parent" out += " " + nvrtype + " " + name + "_pub%s(" % nameSuffix - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if "::" in ptype: @@ -3341,7 +3338,7 @@ def outputMuQtNativeDeclaration(self): if parent: out += self.name + "::" out += name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3440,7 +3437,7 @@ def outputSourceFiles(self): elif line.find("{%%propExclusions%%}") != -1: if len(self.demotedProps): s = " const char* propExclusions[] = {" - for i in range(0, len(self.demotedProps)): + for i in range(len(self.demotedProps)): if i != 0: s += ", " s += '"%s"' % self.demotedProps[i][0] @@ -3465,7 +3462,7 @@ def outputSourceFiles(self): cpplines.append(string.replace(line, "$T", self.name)) cppfile.close() - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): line = cpplines[i] if len(line) >= 1 and line[-1] != "\n": cpplines[i] = line + "\n" @@ -3543,7 +3540,7 @@ def outputModuleDefinition(self, finishedMap): inherits = filter(lambda x: not x.isinterface, self.inherits) inherits.sort(inheritCMP) if self not in finishedMap: - print("Processing {0}...".format(self.name)) + print(f"Processing {self.name}...") if self.name in includeClasses: print("... is in includeClasses") if len(inherits) > 0: @@ -3553,7 +3550,7 @@ def outputModuleDefinition(self, finishedMap): self.name, self.name, ) - for i in range(0, len(inherits)): + for i in range(len(inherits)): out += ", t_%s" % inherits[i].name out += ");" else: @@ -3835,9 +3832,7 @@ def handle_data(self, data): return elif data == "Obsolete flags:": # note obsolete self.defenum = False - elif data == " (preliminary)": # shows up in qwidget.html, messes up everything - return - elif data == " (deprecated)": # shows up in qprocess.html, messes up everything + elif data == " (preliminary)" or data == " (deprecated)": # shows up in qwidget.html, messes up everything return elif self.modulespan and "Q" in data: self.module = data @@ -4034,7 +4029,7 @@ def recursiveParse(url): # if "qwidget.html" in u: absPath = os.path.join(os.path.dirname(url), u) recursiveParse(absPath) - except IOError: + except OSError: print("FAILED: (IOError)", url) except Exception: sys.stdout.flush() @@ -4188,7 +4183,7 @@ def findHTMLinDocTree(rootname): muOutputClasses = sortHierarchically(muOutputClasses) for c in muOutputClasses: - print("output module definition for {0}".format(c.name)) + print(f"output module definition for {c.name}") out += c.outputModuleDefinition(finishedMap) out += "return t_QWidget;\n" diff --git a/src/lib/mu/MuQt6/qt68_to_mu.py b/src/lib/mu/MuQt6/qt68_to_mu.py index 6c6bc868e..23817ff1e 100755 --- a/src/lib/mu/MuQt6/qt68_to_mu.py +++ b/src/lib/mu/MuQt6/qt68_to_mu.py @@ -18,15 +18,16 @@ # # NOTE: this script is Python 2 only (sgmllib, dict.has_key, string.replace). # -from sgmllib import SGMLParser -import urllib -import sys -import traceback +import os +import pickle import pprint -import string import re -import pickle -import os +import string +import sys +import traceback +import urllib + +from sgmllib import SGMLParser # # Qt 5 splits the docs into subdirs which complicates things slightly. @@ -834,7 +835,7 @@ def constReferenceType(t): def indexOf(element, sequence): - for i in range(0, len(sequence)): + for i in range(len(sequence)): if element == sequence[i]: return i return -1 @@ -2060,7 +2061,7 @@ def parseFunction(func, qtnamespace): message("Params: " + str(params)) # make new name for params with same name as func - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # Compare the first element of p and the last element of nameproto. message("Before comparison: " + str(p) + " with " + str(nameproto)) @@ -2086,7 +2087,7 @@ def parseFunction(func, qtnamespace): message("WARNING: Nameproto empty for " + func) except Exception: # Skip any function that has issue with the simple parsing above. - print("Error parsing function.. skipping: {0}".format(orig_func)) + print(f"Error parsing function.. skipping: {orig_func}") return None return None @@ -2222,7 +2223,7 @@ def fullEnumName(self, name): return None def finish(self): - for q in range(0, len(self.functions)): + for q in range(len(self.functions)): f = self.functions[q] (name, fconst, params, rtype, prop) = f ctype = self.name + "::" + rtype @@ -2238,7 +2239,7 @@ def finish(self): (name, fconst, params, rtype, prop) = self.functions[q] - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p ctype = self.name + "::" + ptype @@ -2372,12 +2373,8 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): self.isconst = "const" in const self.purevirtual = "= 0" in qtfunc[1] - print("Processing function {0}".format(qtfunc)) - print( - "failed: {0}, isprop: {1}, isprotected: {2}".format( - str(self.failed), str(self.isprop), str(self.isprotected) - ) - ) + print(f"Processing function {qtfunc}") + print(f"failed: {self.failed!s}, isprop: {self.isprop!s}, isprotected: {self.isprotected!s}") if self.operator: self.name = name[8 : len(name)] @@ -2449,7 +2446,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): fargs = len(f.args) if fargs == nargs and not f.failed: samecount = 0 - for i in range(0, nargs): + for i in range(nargs): a = f.args[i][1] b = self.args[i][1] if a.startswith("flags"): @@ -2471,7 +2468,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): for a in self.args: self.compiled += "_%s" % mangleName(conditionType(a[1])) - print("self.compiled={0}, {1}".format(self.compiled, self.failed)) + print(f"self.compiled={self.compiled}, {self.failed}") def unpackReturnValue(self, expr): rtype = conditionType(self.rtype) @@ -2522,7 +2519,7 @@ def symbolDeclaration(self): return out def nodeImplementation(self): - print("nodeImplementation -> {0}".format(self.name)) + print(f"nodeImplementation -> {self.name}") if self.failed: return "// MISSING NODE: %s" % self.muDeclaration() if self.abstract and self.isconstructor and not self.muclass.inheritable: @@ -2591,7 +2588,7 @@ def compiledFunction(self): else: print("FAILED to find", self.rtype) - print("Compiled function for {0}".format(muclass.name)) + print(f"Compiled function for {muclass.name}") isQObject = muclass.isAByName("QObject") isQPaintDevice = muclass.isAByName("QPaintDevice") @@ -2696,7 +2693,7 @@ def compiledFunction(self): # else: expr = "%s::%s(" % (muclass.qt.name, callname) - for i in range(0, len(self.args)): + for i in range(len(self.args)): a = self.args[i] (aname, atype, aval) = a (dexpr, dtype) = self.derefArg(a) @@ -3078,7 +3075,7 @@ def outputCompiledNodes(self): def outputNodeImplementations(self): out = "" - print("self.statics for {0}".format(self.name)) + print(f"self.statics for {self.name}") for f in filter(self.F_trans, self.functions + self.statics + self.castoperators): out += f.nodeImplementation() @@ -3117,7 +3114,7 @@ def assembleIncludes(self, cpplines): itypes = set([]) endinclude = 0 - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): m = makeRE.search(cpplines[i]) if "#include" in cpplines[i]: endinclude = i @@ -3285,7 +3282,7 @@ def outputMuQtNativeImplementation(self): out += rtype_clean + " MuQt_" + self.name + "::" + name + "(" # args - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3297,7 +3294,7 @@ def outputMuQtNativeImplementation(self): if f.isconstructor: # call the base class constr out += "\n : " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3336,7 +3333,7 @@ def outputMuQtNativeImplementation(self): else: out += "return " out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3354,7 +3351,7 @@ def outputMuQtNativeImplementation(self): # if f.name == "splitPath": # print str(parms) out += " args[0] = Value(Pointer(_obj));\n" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # print str(f.args[i+1]) out += " args[%d] = Value(%s);\n" % ( @@ -3373,7 +3370,7 @@ def outputMuQtNativeImplementation(self): out += "defaultValue<%s>();\n" % rtype_clean else: out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3419,7 +3416,7 @@ def outputMuQtNativeDeclaration(self): out += " " + "MuQt_" + name + "(Pointer muobj, const CallEnvironment*" else: out += " " + rtype + " " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3440,7 +3437,7 @@ def outputMuQtNativeDeclaration(self): if parent: nameSuffix = "_parent" out += " " + nvrtype + " " + name + "_pub%s(" % nameSuffix - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if "::" in ptype: @@ -3455,7 +3452,7 @@ def outputMuQtNativeDeclaration(self): if parent: out += self.name + "::" out += name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3554,7 +3551,7 @@ def outputSourceFiles(self): elif line.find("{%%propExclusions%%}") != -1: if len(self.demotedProps): s = " const char* propExclusions[] = {" - for i in range(0, len(self.demotedProps)): + for i in range(len(self.demotedProps)): if i != 0: s += ", " s += '"%s"' % self.demotedProps[i][0] @@ -3579,7 +3576,7 @@ def outputSourceFiles(self): cpplines.append(string.replace(line, "$T", self.name)) cppfile.close() - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): line = cpplines[i] if len(line) >= 1 and line[-1] != "\n": cpplines[i] = line + "\n" @@ -3657,7 +3654,7 @@ def outputModuleDefinition(self, finishedMap): inherits = filter(lambda x: not x.isinterface, self.inherits) inherits.sort(inheritCMP) if self not in finishedMap: - print("Processing {0}...".format(self.name)) + print(f"Processing {self.name}...") if self.name in includeClasses: print("... is in includeClasses") if len(inherits) > 0: @@ -3667,7 +3664,7 @@ def outputModuleDefinition(self, finishedMap): self.name, self.name, ) - for i in range(0, len(inherits)): + for i in range(len(inherits)): out += ", t_%s" % inherits[i].name out += ");" else: @@ -3949,9 +3946,7 @@ def handle_data(self, data): return elif data == "Obsolete flags:": # note obsolete self.defenum = False - elif data == " (preliminary)": # shows up in qwidget.html, messes up everything - return - elif data == " (deprecated)": # shows up in qprocess.html, messes up everything + elif data == " (preliminary)" or data == " (deprecated)": # shows up in qwidget.html, messes up everything return elif self.modulespan and "Q" in data: self.module = data @@ -4148,7 +4143,7 @@ def recursiveParse(url): # if "qwidget.html" in u: absPath = os.path.join(os.path.dirname(url), u) recursiveParse(absPath) - except IOError: + except OSError: print("FAILED: (IOError)", url) except Exception: sys.stdout.flush() @@ -4301,7 +4296,7 @@ def findHTMLinDocTree(rootname): muOutputClasses = sortHierarchically(muOutputClasses) for c in muOutputClasses: - print("output module definition for {0}".format(c.name)) + print(f"output module definition for {c.name}") out += c.outputModuleDefinition(finishedMap) out += "return t_QWidget;\n" diff --git a/src/lib/mu/MuQt6/qt6_to_mu.py b/src/lib/mu/MuQt6/qt6_to_mu.py index f46fa1b72..d9a7a6dd8 100755 --- a/src/lib/mu/MuQt6/qt6_to_mu.py +++ b/src/lib/mu/MuQt6/qt6_to_mu.py @@ -4,15 +4,16 @@ # # SPDX-License-Identifier: Apache-2.0 # -from sgmllib import SGMLParser -import urllib -import sys -import traceback +import os +import pickle import pprint -import string import re -import pickle -import os +import string +import sys +import traceback +import urllib + +from sgmllib import SGMLParser # # Qt 5 splits the docs into subdirs which complicates things slightly. @@ -816,7 +817,7 @@ def constReferenceType(t): def indexOf(element, sequence): - for i in range(0, len(sequence)): + for i in range(len(sequence)): if element == sequence[i]: return i return -1 @@ -1956,7 +1957,7 @@ def parseFunction(func, qtnamespace): message("Params: " + str(params)) # make new name for params with same name as func - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # Compare the first element of p and the last element of nameproto. message("Before comparison: " + str(p) + " with " + str(nameproto)) @@ -1982,7 +1983,7 @@ def parseFunction(func, qtnamespace): message("WARNING: Nameproto empty for " + func) except Exception: # Skip any function that has issue with the simple parsing above. - print("Error parsing function.. skipping: {0}".format(orig_func)) + print(f"Error parsing function.. skipping: {orig_func}") return None return None @@ -2118,7 +2119,7 @@ def fullEnumName(self, name): return None def finish(self): - for q in range(0, len(self.functions)): + for q in range(len(self.functions)): f = self.functions[q] (name, fconst, params, rtype, prop) = f ctype = self.name + "::" + rtype @@ -2134,7 +2135,7 @@ def finish(self): (name, fconst, params, rtype, prop) = self.functions[q] - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p ctype = self.name + "::" + ptype @@ -2268,12 +2269,8 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): self.isconst = "const" in const self.purevirtual = "= 0" in qtfunc[1] - print("Processing function {0}".format(qtfunc)) - print( - "failed: {0}, isprop: {1}, isprotected: {2}".format( - str(self.failed), str(self.isprop), str(self.isprotected) - ) - ) + print(f"Processing function {qtfunc}") + print(f"failed: {self.failed!s}, isprop: {self.isprop!s}, isprotected: {self.isprotected!s}") if self.operator: self.name = name[8 : len(name)] @@ -2345,7 +2342,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): fargs = len(f.args) if fargs == nargs and not f.failed: samecount = 0 - for i in range(0, nargs): + for i in range(nargs): a = f.args[i][1] b = self.args[i][1] if a.startswith("flags"): @@ -2367,7 +2364,7 @@ def __init__(self, api, muclass, qtfunc, isMember, isProtected, isCastOp): for a in self.args: self.compiled += "_%s" % mangleName(conditionType(a[1])) - print("self.compiled={0}, {1}".format(self.compiled, self.failed)) + print(f"self.compiled={self.compiled}, {self.failed}") def unpackReturnValue(self, expr): rtype = conditionType(self.rtype) @@ -2418,7 +2415,7 @@ def symbolDeclaration(self): return out def nodeImplementation(self): - print("nodeImplementation -> {0}".format(self.name)) + print(f"nodeImplementation -> {self.name}") if self.failed: return "// MISSING NODE: %s" % self.muDeclaration() if self.abstract and self.isconstructor and not self.muclass.inheritable: @@ -2487,7 +2484,7 @@ def compiledFunction(self): else: print("FAILED to find", self.rtype) - print("Compiled function for {0}".format(muclass.name)) + print(f"Compiled function for {muclass.name}") isQObject = muclass.isAByName("QObject") isQPaintDevice = muclass.isAByName("QPaintDevice") @@ -2592,7 +2589,7 @@ def compiledFunction(self): # else: expr = "%s::%s(" % (muclass.qt.name, callname) - for i in range(0, len(self.args)): + for i in range(len(self.args)): a = self.args[i] (aname, atype, aval) = a (dexpr, dtype) = self.derefArg(a) @@ -2964,7 +2961,7 @@ def outputCompiledNodes(self): def outputNodeImplementations(self): out = "" - print("self.statics for {0}".format(self.name)) + print(f"self.statics for {self.name}") for f in filter(self.F_trans, self.functions + self.statics + self.castoperators): out += f.nodeImplementation() @@ -3003,7 +3000,7 @@ def assembleIncludes(self, cpplines): itypes = set([]) endinclude = 0 - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): m = makeRE.search(cpplines[i]) if "#include" in cpplines[i]: endinclude = i @@ -3171,7 +3168,7 @@ def outputMuQtNativeImplementation(self): out += rtype_clean + " MuQt_" + self.name + "::" + name + "(" # args - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3183,7 +3180,7 @@ def outputMuQtNativeImplementation(self): if f.isconstructor: # call the base class constr out += "\n : " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3222,7 +3219,7 @@ def outputMuQtNativeImplementation(self): else: out += "return " out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3240,7 +3237,7 @@ def outputMuQtNativeImplementation(self): # if f.name == "splitPath": # print str(parms) out += " args[0] = Value(Pointer(_obj));\n" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] # print str(f.args[i+1]) out += " args[%d] = Value(%s);\n" % ( @@ -3259,7 +3256,7 @@ def outputMuQtNativeImplementation(self): out += "defaultValue<%s>();\n" % rtype_clean else: out += self.name + "::" + f.name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3305,7 +3302,7 @@ def outputMuQtNativeDeclaration(self): out += " " + "MuQt_" + name + "(Pointer muobj, const CallEnvironment*" else: out += " " + rtype + " " + name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0 or f.isconstructor: @@ -3326,7 +3323,7 @@ def outputMuQtNativeDeclaration(self): if parent: nameSuffix = "_parent" out += " " + nvrtype + " " + name + "_pub%s(" % nameSuffix - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if "::" in ptype: @@ -3341,7 +3338,7 @@ def outputMuQtNativeDeclaration(self): if parent: out += self.name + "::" out += name + "(" - for i in range(0, len(params)): + for i in range(len(params)): p = params[i] (pname, ptype, pval) = p if i > 0: @@ -3440,7 +3437,7 @@ def outputSourceFiles(self): elif line.find("{%%propExclusions%%}") != -1: if len(self.demotedProps): s = " const char* propExclusions[] = {" - for i in range(0, len(self.demotedProps)): + for i in range(len(self.demotedProps)): if i != 0: s += ", " s += '"%s"' % self.demotedProps[i][0] @@ -3465,7 +3462,7 @@ def outputSourceFiles(self): cpplines.append(string.replace(line, "$T", self.name)) cppfile.close() - for i in range(0, len(cpplines)): + for i in range(len(cpplines)): line = cpplines[i] if len(line) >= 1 and line[-1] != "\n": cpplines[i] = line + "\n" @@ -3543,7 +3540,7 @@ def outputModuleDefinition(self, finishedMap): inherits = filter(lambda x: not x.isinterface, self.inherits) inherits.sort(inheritCMP) if self not in finishedMap: - print("Processing {0}...".format(self.name)) + print(f"Processing {self.name}...") if self.name in includeClasses: print("... is in includeClasses") if len(inherits) > 0: @@ -3553,7 +3550,7 @@ def outputModuleDefinition(self, finishedMap): self.name, self.name, ) - for i in range(0, len(inherits)): + for i in range(len(inherits)): out += ", t_%s" % inherits[i].name out += ");" else: @@ -3835,9 +3832,7 @@ def handle_data(self, data): return elif data == "Obsolete flags:": # note obsolete self.defenum = False - elif data == " (preliminary)": # shows up in qwidget.html, messes up everything - return - elif data == " (deprecated)": # shows up in qprocess.html, messes up everything + elif data == " (preliminary)" or data == " (deprecated)": # shows up in qwidget.html, messes up everything return elif self.modulespan and "Q" in data: self.module = data @@ -4034,7 +4029,7 @@ def recursiveParse(url): # if "qwidget.html" in u: absPath = os.path.join(os.path.dirname(url), u) recursiveParse(absPath) - except IOError: + except OSError: print("FAILED: (IOError)", url) except Exception: sys.stdout.flush() @@ -4187,7 +4182,7 @@ def findHTMLinDocTree(rootname): muOutputClasses = sortHierarchically(muOutputClasses) for c in muOutputClasses: - print("output module definition for {0}".format(c.name)) + print(f"output module definition for {c.name}") out += c.outputModuleDefinition(finishedMap) out += "return t_QWidget;\n" diff --git a/src/plugins/output/AJADevices/KonaVideoDevice.cpp b/src/plugins/output/AJADevices/KonaVideoDevice.cpp index 487003ed4..10dc83f1e 100644 --- a/src/plugins/output/AJADevices/KonaVideoDevice.cpp +++ b/src/plugins/output/AJADevices/KonaVideoDevice.cpp @@ -211,31 +211,29 @@ namespace AJADevices KonaVideo4KTransport video4KTransports[] = {{"Quadrants 4-wire", VIDEO_4K_TRANSPORT_QUADRANTS}, {"SMPTE 2SI", VIDEO_4K_TRANSPORT_TSI}}; - KonaDataFormat dataFormatsCP[] = { - // - // In this case we're going to get everything from the AJA - // control panel. - // - - {"AJA Control Panel", (NTV2FrameBufferFormat)999, VideoDevice::RGB8, DataFormatFlags::NoFlags}, - // End of list - {"", (NTV2FrameBufferFormat)999, VideoDevice::RGB8, DataFormatFlags::NoFlags}}; - - KonaDataFormat dataFormatsYUV[] = { - // - // These are for t-tap: it can only receive YUV formats so the - // renderer will use the GPU to convert to YUV and then in - // software we do the 4:2:2 down convert (until we have a packing - // shader). - // - // Using GL_PACK_ROW_LENGTH slows down glReadPixels sufficiently - // to make it not worthwhile. - // - - {"8 Bit YCrCb 4:2:2 (YUV-8)", NTV2_FBF_8BIT_YCBCR, VideoDevice::Y0CbY1Cr_8_422, P2P}, - {"10 Bit YCrCb 4:2:2 (YUV-10)", NTV2_FBF_10BIT_YCBCR, VideoDevice::YCrCb_AJA_10_422, P2P}, - // End of list - {"", NTV2_FBF_10BIT_YCBCR, VideoDevice::YCrCb_AJA_10_422, P2P}}; + KonaDataFormat dataFormatsCP[] = {// + // In this case we're going to get everything from the AJA + // control panel. + // + + {"AJA Control Panel", (NTV2FrameBufferFormat)999, VideoDevice::RGB8, DataFormatFlags::NoFlags}, + // End of list + {"", (NTV2FrameBufferFormat)999, VideoDevice::RGB8, DataFormatFlags::NoFlags}}; + + KonaDataFormat dataFormatsYUV[] = {// + // These are for t-tap: it can only receive YUV formats so the + // renderer will use the GPU to convert to YUV and then in + // software we do the 4:2:2 down convert (until we have a packing + // shader). + // + // Using GL_PACK_ROW_LENGTH slows down glReadPixels sufficiently + // to make it not worthwhile. + // + + {"8 Bit YCrCb 4:2:2 (YUV-8)", NTV2_FBF_8BIT_YCBCR, VideoDevice::Y0CbY1Cr_8_422, P2P}, + {"10 Bit YCrCb 4:2:2 (YUV-10)", NTV2_FBF_10BIT_YCBCR, VideoDevice::YCrCb_AJA_10_422, P2P}, + // End of list + {"", NTV2_FBF_10BIT_YCBCR, VideoDevice::YCrCb_AJA_10_422, P2P}}; KonaDataFormat dataFormats[] = { // diff --git a/src/plugins/python/gtoContainer/gtoContainer.py b/src/plugins/python/gtoContainer/gtoContainer.py index 2f88a59ee..067485f3e 100755 --- a/src/plugins/python/gtoContainer/gtoContainer.py +++ b/src/plugins/python/gtoContainer/gtoContainer.py @@ -105,11 +105,12 @@ """ -from types import * -import re -import gto import operator +import re from functools import reduce +from types import * + +import gto import six @@ -407,7 +408,7 @@ def __setattr__(self, name, value): def __delattr__(self, name): if name in self.__dict__: del self.__dict__[name] - for p in range(0, len(self.__properties)): + for p in range(len(self.__properties)): if self.__properties[p].name() == name: del self.__properties[p] return @@ -631,7 +632,7 @@ def __setattr__(self, name, value): def __delattr__(self, name): if name in self.__dict__: del self.__dict__[name] - for c in range(0, len(self.__components)): + for c in range(len(self.__components)): if self.__components[c].name() == name: del self.__components[c] return @@ -911,7 +912,7 @@ def __setattr__(self, name, value): def __delattr__(self, name): if name in self.__dict__: del self.__dict__[name] - for o in range(0, len(self.__objects)): + for o in range(len(self.__objects)): if self.__objects[o].name() == name: del self.__objects[o] return diff --git a/src/plugins/python/network/network/addSource.py b/src/plugins/python/network/network/addSource.py index 74e7b85a0..a305ce9b4 100755 --- a/src/plugins/python/network/network/addSource.py +++ b/src/plugins/python/network/network/addSource.py @@ -5,9 +5,10 @@ # SPDX-License-Identifier: Apache-2.0 # -import rvNetwork import sys +import rvNetwork + if len(sys.argv) != 3: print("usage: %s " % sys.argv[0]) exit(1) diff --git a/src/plugins/python/network/network/muConsole.py b/src/plugins/python/network/network/muConsole.py index 2c4615f48..e84adee78 100755 --- a/src/plugins/python/network/network/muConsole.py +++ b/src/plugins/python/network/network/muConsole.py @@ -5,10 +5,11 @@ # SPDX-License-Identifier: Apache-2.0 # -import rvNetwork import sys import time +import rvNetwork + class MuConsoleException(Exception): pass @@ -42,5 +43,5 @@ def run(self): mu = MuConsole() mu.run() except MuConsoleException as inst: - print((str(inst))) + print(str(inst)) sys.exit(-1) diff --git a/src/plugins/python/network/network/playControl.py b/src/plugins/python/network/network/playControl.py index fea7eb7fe..63105cef4 100755 --- a/src/plugins/python/network/network/playControl.py +++ b/src/plugins/python/network/network/playControl.py @@ -5,12 +5,13 @@ # SPDX-License-Identifier: Apache-2.0 # -import rvNetwork +import select import sys import time -import select import tty +import rvNetwork + class PlayControl: def __init__(self, host, port=45124): diff --git a/src/plugins/python/network/network/rvNetwork.py b/src/plugins/python/network/network/rvNetwork.py index 36611a040..6a121e8f0 100755 --- a/src/plugins/python/network/network/rvNetwork.py +++ b/src/plugins/python/network/network/rvNetwork.py @@ -4,11 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 # -from __future__ import print_function import socket import sys import time + import six @@ -57,13 +57,13 @@ def connect(self, host, port=-1): try: self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - except socket.error as msg: + except OSError as msg: print("ERROR: can't create socket: %s\n" % msg[1], file=sys.stderr) return try: self.sock.connect((host, self.port)) - except socket.error as msg: + except OSError as msg: print("ERROR: can't connect: %s\n" % msg[1], file=sys.stderr) return @@ -73,7 +73,7 @@ def connect(self, host, port=-1): self.sock.sendall(six.ensure_binary(msg)) if self.noPingPong: self.sock.sendall(six.ensure_binary("PINGPONGCONTROL 1 0")) - except socket.error as msg: + except OSError as msg: print("ERROR: can't send greeting: %s\n" % msg[1], file=sys.stderr) return @@ -159,7 +159,7 @@ def messageAvailable(self): self.sock.close() self.connected = False - except socket.error as msg: + except OSError as msg: sanitized_msg = msg if hasattr(msg, "errno"): sanitized_msg = (msg.errno, msg.strerror) @@ -194,7 +194,7 @@ def _receiveSingleMessage(self): messContents = self.sock.recv(messSize) self.sock.setblocking(0) - except socket.error as msg: + except OSError as msg: print("ERROR: can't process message: %s\n" % msg[1], file=sys.stderr) self.sock.setblocking(0) diff --git a/src/plugins/python/rvSession/rvSession.py b/src/plugins/python/rvSession/rvSession.py index 1106d6c9b..7eefdc041 100644 --- a/src/plugins/python/rvSession/rvSession.py +++ b/src/plugins/python/rvSession/rvSession.py @@ -67,9 +67,10 @@ """ import sys -import six + import gto import gtoContainer as gc +import six apiName = "rvSession.py" apiVersion = "0.5" @@ -258,7 +259,7 @@ def setMetaData(self, metadata): As a helper, a dictionary can be supplied that will print metadata sorted by the keys """ if isinstance(metadata, dict): - metadata = ["{0}={1}".format(k, v) for k, v in sorted(metadata.items(), reverse=True)] + metadata = [f"{k}={v}" for k, v in sorted(metadata.items(), reverse=True)] self.setProperty( "RVFileSource", @@ -407,7 +408,7 @@ def setText(self, text, count=0, frame=1): if k not in ["order", "sourceCount", "name"]: if isinstance(v, str): valueType = gto.STRING - self.setProperty("RVPaint", "paint", self.txt.name, "{0}".format(k), valueType, v) + self.setProperty("RVPaint", "paint", self.txt.name, f"{k}", valueType, v) # For layout, but not source # self.txt.order.append(self.txt.name) return self.txt.name @@ -419,7 +420,7 @@ def setFrameNumberForText(self, frame, setTextName): self.setProperty( "RVPaint", "paint", - "frame:{0:d}".format(int(frame)), + f"frame:{int(frame):d}", "order", gto.STRING, setTextName, @@ -606,7 +607,7 @@ def setText(self, text, count=0, frame=1): if k not in ["order", "sourceCount", "name"]: if isinstance(v, str): valueType = gto.STRING - self.setProperty("RVPaint", "paint", self.txt.name, "{0}".format(k), valueType, v) + self.setProperty("RVPaint", "paint", self.txt.name, f"{k}", valueType, v) self.txt.order.append(self.txt.name) def setFrameNumberForText(self, frame): @@ -616,7 +617,7 @@ def setFrameNumberForText(self, frame): self.setProperty( "RVPaint", "paint", - "frame:{0:d}".format(int(frame)), + f"frame:{int(frame):d}", "order", gto.STRING, self.txt.order, @@ -645,9 +646,9 @@ def createTileList(self, numTiles): scale = 1.0 / nside pos = [] - for row in reversed(range(0, nside)): + for row in reversed(range(nside)): y = scale * row - (0.5 * scale) - for column in range(0, nside): + for column in range(nside): x = scale * column pos.append((x * 2, y)) @@ -664,7 +665,7 @@ def tile(self, images): tileList = self.createTileList(len(images)) scale = tileList[0] pos = tileList[1] - for i in range(0, len(images)): + for i in range(len(images)): img = images[i] x, y = pos[i] tileDict[img] = (x, y) @@ -832,7 +833,7 @@ def _writeProperties(self, top, obj, objName, properties): (subObjType, subObject, container, prop) = path (typeName, value) = info - if subObject not in subObjects.keys(): + if subObject not in subObjects: # # This property belongs in a subObject we haven't # created yet, so do it now. @@ -1280,4 +1281,3 @@ def buildOutputColor (session) : s.write ("sample.rv") """ - pass diff --git a/src/plugins/rv-packages/annot_tools/annot_tools.py b/src/plugins/rv-packages/annot_tools/annot_tools.py index 593d8e0d8..f94e074b2 100644 --- a/src/plugins/rv-packages/annot_tools/annot_tools.py +++ b/src/plugins/rv-packages/annot_tools/annot_tools.py @@ -56,26 +56,26 @@ def annotate_first_source(self, _): paint_node = rvec.associatedNode("RVPaint", source_node) for frame in range(source_data["startFrame"], source_data["endFrame"] + 1): - paint_prop = "{}.paint".format(paint_node) - text_name = "text:{}:{}:annotation".format(rvc.getIntProperty("{}.nextId".format(paint_prop))[0], frame) - text_prop = "{}.{}".format(paint_node, text_name) + paint_prop = f"{paint_node}.paint" + text_name = "text:{}:{}:annotation".format(rvc.getIntProperty(f"{paint_prop}.nextId")[0], frame) + text_prop = f"{paint_node}.{text_name}" rvc.setIntProperty("{}.{}".format(paint_prop, "show"), [1]) rvc.newProperty("{}.{}".format(text_prop, "text"), rvc.StringType, 1) rvc.newProperty("{}.{}".format(text_prop, "position"), rvc.FloatType, 2) rvc.newProperty("{}.{}".format(text_prop, "color"), rvc.FloatType, 4) rvc.newProperty("{}.{}".format(text_prop, "size"), rvc.FloatType, 1) - rvc.newProperty("{}.frame:{}.order".format(paint_node, frame), rvc.StringType, 1) + rvc.newProperty(f"{paint_node}.frame:{frame}.order", rvc.StringType, 1) rvc.setStringProperty( "{}.{}".format(text_prop, "text"), - ["This is frame {}".format(frame)], + [f"This is frame {frame}"], True, ) rvc.setFloatProperty("{}.{}".format(text_prop, "position"), [-0.6, 0.24], True) rvc.setFloatProperty("{}.{}".format(text_prop, "color"), [1.0, 1.0, 1.0, 1.0], True) rvc.setFloatProperty("{}.{}".format(text_prop, "size"), [0.01], True) - rvc.setStringProperty("{}.frame:{}.order".format(paint_node, frame), [text_name], True) + rvc.setStringProperty(f"{paint_node}.frame:{frame}.order", [text_name], True) g_the_mode = None diff --git a/src/plugins/rv-packages/annotate_beta/annotate_beta_color_picker.py b/src/plugins/rv-packages/annotate_beta/annotate_beta_color_picker.py index e22edce21..0cd0acb19 100644 --- a/src/plugins/rv-packages/annotate_beta/annotate_beta_color_picker.py +++ b/src/plugins/rv-packages/annotate_beta/annotate_beta_color_picker.py @@ -1,7 +1,7 @@ # Copyright (c) 2026 Autodesk, Inc. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -from PySide6 import QtCore, QtWidgets, QtGui +from PySide6 import QtCore, QtGui, QtWidgets _PRESETS = [ "#FF3B30", # red diff --git a/src/plugins/rv-packages/annotate_beta/annotate_beta_engine.py b/src/plugins/rv-packages/annotate_beta/annotate_beta_engine.py index 6bac6f54d..b2dbc53eb 100644 --- a/src/plugins/rv-packages/annotate_beta/annotate_beta_engine.py +++ b/src/plugins/rv-packages/annotate_beta/annotate_beta_engine.py @@ -7,10 +7,9 @@ from functools import partial from typing import NamedTuple -from rv import commands - import annotate_beta_constants as constants import annotate_beta_paint as paint +from rv import commands _PREFIX = { constants.Tool.RECT: "rect", diff --git a/src/plugins/rv-packages/annotate_beta/annotate_beta_mode.py b/src/plugins/rv-packages/annotate_beta/annotate_beta_mode.py index f460e1f0d..65f32aa44 100644 --- a/src/plugins/rv-packages/annotate_beta/annotate_beta_mode.py +++ b/src/plugins/rv-packages/annotate_beta/annotate_beta_mode.py @@ -3,14 +3,12 @@ from functools import partial -from rv import commands, extra_commands, rvtypes, qtutils - -from PySide6 import QtCore, QtWidgets, QtGui - import annotate_beta_constants as constants import annotate_beta_paint as paint from annotate_beta_engine import AnnotateDrawEngine, DrawSettings, ToolState from annotate_beta_widget import AnnotateToolbarDockWidget +from PySide6 import QtCore, QtGui, QtWidgets +from rv import commands, extra_commands, qtutils, rvtypes _TOOL_CURSORS = {constants.Tool.CURSOR: QtCore.Qt.ArrowCursor, constants.Tool.TEXT: QtCore.Qt.IBeamCursor} diff --git a/src/plugins/rv-packages/annotate_beta/annotate_beta_paint.py b/src/plugins/rv-packages/annotate_beta/annotate_beta_paint.py index bcfc7fc80..1c18df138 100644 --- a/src/plugins/rv-packages/annotate_beta/annotate_beta_paint.py +++ b/src/plugins/rv-packages/annotate_beta/annotate_beta_paint.py @@ -6,9 +6,8 @@ import os import uuid -from rv import commands - import annotate_beta_constants as constants +from rv import commands BOX_PREFIXES = frozenset({"rect", "ellipse"}) diff --git a/src/plugins/rv-packages/annotate_beta/annotate_beta_widget.py b/src/plugins/rv-packages/annotate_beta/annotate_beta_widget.py index 33b799632..96b10bbd4 100644 --- a/src/plugins/rv-packages/annotate_beta/annotate_beta_widget.py +++ b/src/plugins/rv-packages/annotate_beta/annotate_beta_widget.py @@ -3,15 +3,13 @@ import os import sys - from dataclasses import dataclass from enum import Enum, auto from functools import partial -from PySide6 import QtCore, QtWidgets, QtGui - -from annotate_beta_color_picker import ColorPickerPopup import annotate_beta_constants as constants +from annotate_beta_color_picker import ColorPickerPopup +from PySide6 import QtCore, QtGui, QtWidgets class _Page(Enum): diff --git a/src/plugins/rv-packages/collapse_missing_frames/collapse_missing_frames.py b/src/plugins/rv-packages/collapse_missing_frames/collapse_missing_frames.py index c04e5de55..5594bce9f 100755 --- a/src/plugins/rv-packages/collapse_missing_frames/collapse_missing_frames.py +++ b/src/plugins/rv-packages/collapse_missing_frames/collapse_missing_frames.py @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes, commands +from rv import commands, rvtypes def groupMemberOfType(node, memberType): diff --git a/src/plugins/rv-packages/custom_lut_menu_mode/custom_lut_menu_mode.py b/src/plugins/rv-packages/custom_lut_menu_mode/custom_lut_menu_mode.py index 022f0b6b2..78fa79fc2 100644 --- a/src/plugins/rv-packages/custom_lut_menu_mode/custom_lut_menu_mode.py +++ b/src/plugins/rv-packages/custom_lut_menu_mode/custom_lut_menu_mode.py @@ -3,9 +3,10 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes, commands, extra_commands import os +from rv import commands, extra_commands, rvtypes + CDLS = ["cc", "ccc", "cdl"] LUTS = [ "3dl", @@ -145,7 +146,7 @@ def setLUT(self, path, lutNode, display=False): self.restoreDefaultProps(lutNode, display) except Exception as inst: extra_commands.displayFeedback("LUT File Failed to Read: Check File %s" % path, 5.0) - print(("ERROR: Failed to set LUT '%s' for %s: %s" % (path, lutNode, str(inst)))) + print("ERROR: Failed to set LUT '%s' for %s: %s" % (path, lutNode, str(inst))) def sourceColorSetup(self, event): # IF No Linearization is set, turn off all To->Linear Conversions @@ -159,7 +160,7 @@ def sourceColorSetup(self, event): for lut in self.lutNodes.keys(): if self.lutNodes[lut].startswith("#") and self._autoLoadCXfrm[lut]: if self._autoFormat[lut] != "": - print(("INFO: Searching for accompanying '%s'" % self._autoFormat[lut])) + print("INFO: Searching for accompanying '%s'" % self._autoFormat[lut]) self.loadColorXfrm(lut, event) event.reject() @@ -178,7 +179,7 @@ def displayColorSetup(self, event): if self._autoLoadDLUT: lut = commands.readSettings("CUSTOM_LUTS", "defaultDisplayLut", "NONE") if lut != "NONE": - print(("INFO: Autoloading Default Display LUT: '%s'" % lut)) + print("INFO: Autoloading Default Display LUT: '%s'" % lut) self.setLUT(lut, dnode, True) event.reject() @@ -236,7 +237,7 @@ def loadColorXfrm(self, lut, event): xfrmFile = self._autoLUT[lut] xfrmExt = xfrmFile.split(".")[-1] except Exception: - print(("ERROR: Unable to determine extension from '%s'" % xfrmFile)) + print("ERROR: Unable to determine extension from '%s'" % xfrmFile) else: dirUp = 0 while dirUp < self._autoLevel[lut]: @@ -252,14 +253,14 @@ def loadColorXfrm(self, lut, event): "Unable to find accompanying color" + " transform with extension '%s'" % self._autoFormat[lut], 5.0, ) - print(("WARNING: No '%s' file found in '%s' for '%s'" % (self._autoFormat[lut], containing, movie))) + print("WARNING: No '%s' file found in '%s' for '%s'" % (self._autoFormat[lut], containing, movie)) return try: searchType = self.lutNodes[lut][1:] xfrmNode = extra_commands.associatedNode(searchType, srcNode) except Exception: - print(("ERROR: Unable to find transform node from '%s'" % searchType)) + print("ERROR: Unable to find transform node from '%s'" % searchType) return if xfrmExt in CDLS: @@ -267,7 +268,7 @@ def loadColorXfrm(self, lut, event): commands.readCDL(xfrmFile, xfrmNode, True) except Exception as inst: extra_commands.displayFeedback("CDL File Failed to Read: Check File %s" % xfrmFile, 5.0) - print(("ERROR: Failed to set CDL '%s' for %s: %s" % (xfrmFile, xfrmNode, str(inst)))) + print("ERROR: Failed to set CDL '%s' for %s: %s" % (xfrmFile, xfrmNode, str(inst))) elif xfrmExt in LUTS: self.setLUT(xfrmFile, xfrmNode) diff --git a/src/plugins/rv-packages/custom_mattes/custom_mattes.py b/src/plugins/rv-packages/custom_mattes/custom_mattes.py index 3cd69e83d..264ca0c68 100644 --- a/src/plugins/rv-packages/custom_mattes/custom_mattes.py +++ b/src/plugins/rv-packages/custom_mattes/custom_mattes.py @@ -3,9 +3,10 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import commands, rvtypes, extra_commands import os +from rv import commands, extra_commands, rvtypes + class KnownError(Exception): pass @@ -27,7 +28,7 @@ def __init__(self): if os.path.exists(definition): self.updateMattesFromFile(definition) except KnownError as inst: - print((str(inst))) + print(str(inst)) self.setMenuAndBindings() lastMatte = str(commands.readSettings("CUSTOM_MATTES", "customMatteName", "")) @@ -71,7 +72,7 @@ def selectMattesFile(self, event): try: self.updateMattesFromFile(definition) except KnownError as inst: - print((str(inst))) + print(str(inst)) self.setMenuAndBindings() def setMenuAndBindings(self): @@ -131,7 +132,7 @@ def updateMattesFromFile(self, filename): # parameters order = [] mattes = {} - for line in open(filename).readlines(): + for line in open(filename): tokens = line.strip("\n").split(",") if len(tokens) == 6: order.append(tokens[0]) diff --git a/src/plugins/rv-packages/data_display_indicators/data_display_indicator_mode.py b/src/plugins/rv-packages/data_display_indicators/data_display_indicator_mode.py index ba933feb9..72aa23bca 100644 --- a/src/plugins/rv-packages/data_display_indicators/data_display_indicator_mode.py +++ b/src/plugins/rv-packages/data_display_indicators/data_display_indicator_mode.py @@ -3,19 +3,18 @@ # # SPDX-License-Identifier: Apache-2.0 # -import re import math +import re -import rv.rvtypes as rvt import rv.commands as rvc import rv.extra_commands as rvec - +import rv.rvtypes as rvt from OpenGL.GL import * -from OpenGL.GLUT import * from OpenGL.GLU import * +from OpenGL.GLUT import * -class WireBox(object): +class WireBox: def render(self): glColor(self.r, self.g, self.b, 1.0) glBegin(GL_LINE_LOOP) diff --git a/src/plugins/rv-packages/lat_long_viewer/lat_long_viewer.py b/src/plugins/rv-packages/lat_long_viewer/lat_long_viewer.py index fb05a5132..5ad448f60 100644 --- a/src/plugins/rv-packages/lat_long_viewer/lat_long_viewer.py +++ b/src/plugins/rv-packages/lat_long_viewer/lat_long_viewer.py @@ -3,16 +3,14 @@ # # SPDX-License-Identifier: Apache-2.0 # -from __future__ import print_function +import sys + +import rv.runtime from rv import commands as rvc from rv import extra_commands as rve from rv import rvtypes as rvt -import rv.runtime - -import sys - def deb(s): if False: @@ -159,7 +157,6 @@ def adjustFocalLength(self, event): 'rvui.startParameterMode("#LatLongViewer.parameters.focalLength", 100.0, 7.0, 1.0)(nil);', [], ) - pass def toggleAdjust(self, event): self.adjustAllowed = not self.adjustAllowed diff --git a/src/plugins/rv-packages/media_library_demo/media_library_environment_variable_reader_plugin.py b/src/plugins/rv-packages/media_library_demo/media_library_environment_variable_reader_plugin.py index e02702a7d..8a8c9cfb2 100644 --- a/src/plugins/rv-packages/media_library_demo/media_library_environment_variable_reader_plugin.py +++ b/src/plugins/rv-packages/media_library_demo/media_library_environment_variable_reader_plugin.py @@ -5,13 +5,13 @@ # import os -import requests - +from collections.abc import Iterable from http.cookies import SimpleCookie from tempfile import NamedTemporaryFile -from typing import Dict, Iterable from urllib.parse import urlparse +import requests + # !!!!! W A R N I N G !!!!! # # This is a demo package for RV. It is not meant to be used in production. @@ -88,7 +88,7 @@ def is_redirecting(url: str) -> bool: return urlparse(url).scheme in ["http", "https"] -def get_http_cookies(url: str) -> Iterable[Dict]: +def get_http_cookies(url: str) -> Iterable[dict]: """ Returns a list of cookies to be used for the given url. @@ -116,7 +116,7 @@ def get_http_cookies(url: str) -> Iterable[Dict]: yield from () -def get_http_headers(url: str) -> Iterable[Dict]: +def get_http_headers(url: str) -> Iterable[dict]: """ Returns a list of headers to be used for the given url. diff --git a/src/plugins/rv-packages/media_library_demo/media_library_event_plugin.py b/src/plugins/rv-packages/media_library_demo/media_library_event_plugin.py index 7fc5a5b19..45769d072 100644 --- a/src/plugins/rv-packages/media_library_demo/media_library_event_plugin.py +++ b/src/plugins/rv-packages/media_library_demo/media_library_event_plugin.py @@ -2,7 +2,7 @@ # from rvio because rvio does not support modes. from ast import literal_eval -from typing import Dict, Iterable +from collections.abc import Iterable plugin_enabled = True try: @@ -41,7 +41,7 @@ def is_redirecting(url: str) -> bool: return bool(literal_eval(sendInternalEvent("media-library-is-streaming", url) or "False")) -def get_http_cookies(url: str) -> Iterable[Dict]: +def get_http_cookies(url: str) -> Iterable[dict]: """ Returns a list of cookies to be used for the given url. @@ -72,7 +72,7 @@ def get_http_cookies(url: str) -> Iterable[Dict]: yield from () -def get_http_headers(url: str) -> Iterable[Dict]: +def get_http_headers(url: str) -> Iterable[dict]: """ Returns a list of headers to be used for the given url. diff --git a/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep.py b/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep.py index 7f78f7004..4847206e1 100755 --- a/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep.py +++ b/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep.py @@ -16,12 +16,11 @@ except ImportError: pass -from rv import rvtypes, qtutils +import multiple_source_media_rep_utils as utils +from multiple_source_media_rep_logger import package_logger from rv import commands as rvc from rv import extra_commands as rve - -from multiple_source_media_rep_logger import package_logger -import multiple_source_media_rep_utils as utils +from rv import qtutils, rvtypes class MediaRepresentationItem(QtWidgets.QWidgetAction): @@ -34,7 +33,7 @@ class MediaRepresentationItem(QtWidgets.QWidgetAction): _label = None def __init__(self, parent): - super(MediaRepresentationItem, self).__init__(parent) + super().__init__(parent) self._build_ui() def _build_ui(self): @@ -90,7 +89,7 @@ def mousePressEvent(self, _): self.parentWidget().hide() def setChecked(self, value): - super(MediaRepresentationItem, self).setChecked(value) + super().setChecked(value) self._check_mark.setVisible(value) @@ -175,7 +174,7 @@ def sourceMediaUnavailable(self, event): expectedNumberOfArgs = 3 if len(args) != expectedNumberOfArgs: package_logger.error( - "source-media-unavailable has {} parameters, expected={}".format(len(args), expectedNumberOfArgs) + f"source-media-unavailable has {len(args)} parameters, expected={expectedNumberOfArgs}" ) return @@ -187,15 +186,13 @@ def sourceMediaUnavailable(self, event): fallbackMediaRepName = self._getFallbackMediaRepName(sourceNodeName, mediaRepName) package_logger.debug( - "sourceMediaUnavailable()-sourceNodeName={}, mediaRepName={}, fallbackMediaRepName={}".format( - sourceNodeName, mediaRepName, fallbackMediaRepName - ) + f"sourceMediaUnavailable()-sourceNodeName={sourceNodeName}, mediaRepName={mediaRepName}, fallbackMediaRepName={fallbackMediaRepName}" ) # Select the fallback media rep if fallbackMediaRepName is not None: - fallbackNoticeText = "{} ({}) is not available, falling back to {}".format( - mediaRepName, mediaRepPath, fallbackMediaRepName + fallbackNoticeText = ( + f"{mediaRepName} ({mediaRepPath}) is not available, falling back to {fallbackMediaRepName}" ) rve.displayFeedback(fallbackNoticeText, 3.0) package_logger.info(fallbackNoticeText) @@ -328,7 +325,7 @@ def _populate_media_rep_menu(self, menu, switch_nodes): for switch_node in switch_nodes: reps_and_nodes = rvc.sourceMediaRepsAndNodes(switch_node) for rep, source_node in reps_and_nodes: - if rep in reps_and_source_nodes.keys(): + if rep in reps_and_source_nodes: reps_and_source_nodes[rep].append(source_node) else: reps_and_source_nodes[rep] = [source_node] @@ -336,7 +333,7 @@ def _populate_media_rep_menu(self, menu, switch_nodes): # Fetch the resolution and extension for all the media reps. # The menu items are composed of the media rep name, the extension and # the resolution. - for rep in reps_and_source_nodes.keys(): + for rep in reps_and_source_nodes: source_media_infos = utils.get_common_source_media_infos(reps_and_source_nodes[rep]) action = MediaRepresentationItem(menu) diff --git a/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep_utils.py b/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep_utils.py index 80992a6f2..ba2215c88 100644 --- a/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep_utils.py +++ b/src/plugins/rv-packages/multiple_source_media_rep/multiple_source_media_rep_utils.py @@ -8,11 +8,11 @@ # agreement to the ShotGrid Pipeline Toolkit Source Code License. All rights # not expressly granted therein are reserved by ShotGrid Software Inc. +from collections import namedtuple + from rv import commands as rvc from rv import extra_commands as rve -from collections import namedtuple - def is_url(url): """ diff --git a/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py b/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py index 1a4ef8c2a..597f753ce 100644 --- a/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py +++ b/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py @@ -3,9 +3,10 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes, commands import os + import PyOpenColorIO as OCIO +from rv import commands, rvtypes # # Default implementations of helper methods @@ -284,7 +285,7 @@ def useSourceOCIO(self, source, nodeType, defaultSetting=""): if commands.nodeType(pNode).startswith("OCIO"): commands.ocioUpdateConfig(pNode) - print(("INFO: using %s node for %s %s" % (nodeType, source, pipeSlot))) + print("INFO: using %s node for %s %s" % (nodeType, source, pipeSlot)) return # @@ -320,17 +321,17 @@ def useSourceOCIO(self, source, nodeType, defaultSetting=""): DEFAULT_PIPE[pipeSlot] = currentPipelineNodes pipelineList = ocio_node_from_media(self.config, srcPipeline, DEFAULT_PIPE[pipeSlot], media, attrDict) except Exception as inst: - print(("ERROR: Problem occurred while loading OCIO settings for %s: %s" % (nodeType, inst))) + print("ERROR: Problem occurred while loading OCIO settings for %s: %s" % (nodeType, inst)) return try: pipeline = [p["nodeType"] for p in pipelineList] except KeyError as inst: - print(("ERROR: Unable to make use of ocio_node_from_media return: %s" % inst)) + print("ERROR: Unable to make use of ocio_node_from_media return: %s" % inst) if pipeline == DEFAULT_PIPE[pipeSlot]: return - print(("INFO: using %s node for %s %s" % (nodeType, source, pipeSlot))) + print("INFO: using %s node for %s %s" % (nodeType, source, pipeSlot)) commands.setStringProperty(srcPipeline + ".pipeline.nodes", pipeline, True) pipeNodes = commands.nodesInGroup(srcPipeline) @@ -340,7 +341,7 @@ def useSourceOCIO(self, source, nodeType, defaultSetting=""): try: applyProps(stageOCIO, pNode["context"], pNode["properties"]) except KeyError as inst: - print(("ERROR: Unable to apply properties to %s: %s" % (stageOCIO, inst))) + print("ERROR: Unable to apply properties to %s: %s" % (stageOCIO, inst)) commands.redraw() @@ -358,7 +359,7 @@ def disableSourceOCIO(self, source, nodeType): if pipeSlot not in DEFAULT_PIPE or current == DEFAULT_PIPE[pipeSlot]: return - print(("INFO: resetting %s for %s" % (pipeSlot, source))) + print("INFO: resetting %s for %s" % (pipeSlot, source)) commands.setStringProperty(srcPipeline + ".pipeline.nodes", DEFAULT_PIPE[pipeSlot], True) commands.redraw() @@ -393,18 +394,18 @@ def useDisplayOCIO(self, group): DEFAULT_PIPE[groupName] = currentPipelineNodes pipelineList = ocio_node_from_media(self.config, dpipeline, DEFAULT_PIPE[groupName]) except Exception as inst: - print(("ERROR: Problem occurred while loading OCIO settings for OCIODisplay: %s" % inst)) + print("ERROR: Problem occurred while loading OCIO settings for OCIODisplay: %s" % inst) return try: pipeline = [p["nodeType"] for p in pipelineList] except KeyError as inst: - print(("ERROR: Unable to make use of ocio_node_from_media return: %s" % inst)) + print("ERROR: Unable to make use of ocio_node_from_media return: %s" % inst) if pipeline == DEFAULT_PIPE[groupName]: return device = commands.getStringProperty(group + ".device.name")[0] - print(("INFO: using OCIODisplay for display: %s" % device)) + print("INFO: using OCIODisplay for display: %s" % device) dpipeline = groupMemberOfType(group, groupName) commands.setStringProperty(dpipeline + ".pipeline.nodes", pipeline, True) @@ -416,7 +417,7 @@ def useDisplayOCIO(self, group): try: applyProps(stageOCIO, pNode["context"], pNode["properties"]) except KeyError as inst: - print(("ERROR: Unable to apply properties to %s: %s" % (stageOCIO, inst))) + print("ERROR: Unable to apply properties to %s: %s" % (stageOCIO, inst)) self.usingOCIOForDisplay[group] = True commands.redraw() @@ -438,7 +439,7 @@ def disableDisplayOCIO(self, group): commands.setStringProperty(dpipeline + ".pipeline.nodes", DEFAULT_PIPE[groupName], True) device = commands.getStringProperty(group + ".device.name")[0] - print(("INFO: using RVDisplayColor for display: %s" % device)) + print("INFO: using RVDisplayColor for display: %s" % device) self.usingOCIOForDisplay[group] = False commands.redraw() @@ -459,7 +460,7 @@ def sourceSetup(self, event): imageSource = groupMemberOfType(group, "RVImageSource") source = fileSource if imageSource is None else imageSource - for nodeType in OCIO_ROLES.keys(): + for nodeType in OCIO_ROLES: self.useSourceOCIO(source, nodeType) # @@ -529,13 +530,13 @@ def selectConfig(self, event): self.config = OCIO.Config.CreateFromFile(config) OCIO.SetCurrentConfig(self.config) for source in commands.nodesOfType("RVFileSource") + commands.nodesOfType("RVImageSource"): - for nodeType in OCIO_ROLES.keys(): + for nodeType in OCIO_ROLES: self.disableSourceOCIO(source, nodeType) for group in commands.nodesOfType("RVDisplayGroup"): self.disableDisplayOCIO(group) DEFAULT_PIPE.clear() for source in commands.nodesOfType("RVFileSource") + commands.nodesOfType("RVImageSource"): - for nodeType in OCIO_ROLES.keys(): + for nodeType in OCIO_ROLES: self.useSourceOCIO(source, nodeType) for group in commands.nodesOfType("RVDisplayGroup"): self.usingOCIOForDisplay[group] = False @@ -725,7 +726,7 @@ def __init__(self): except AttributeError: pass - print(("INFO: Using %s for OCIO setup methods: %s" % (rv_ocio_setup.__file__, " ".join(inherited)))) + print("INFO: Using %s for OCIO setup methods: %s" % (rv_ocio_setup.__file__, " ".join(inherited))) except ImportError: pass diff --git a/src/plugins/rv-packages/os_dependent_path_conversion/os_dependent_path_conversion_mode.py b/src/plugins/rv-packages/os_dependent_path_conversion/os_dependent_path_conversion_mode.py index 16ec767cb..b8f897aec 100644 --- a/src/plugins/rv-packages/os_dependent_path_conversion/os_dependent_path_conversion_mode.py +++ b/src/plugins/rv-packages/os_dependent_path_conversion/os_dependent_path_conversion_mode.py @@ -3,10 +3,11 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes import platform import re +from rv import rvtypes + class OSDependentPathConversionModeMinorMode(rvtypes.MinorMode): def fixpath(self, event): diff --git a/src/plugins/rv-packages/otio_reader/annotation_hook.py b/src/plugins/rv-packages/otio_reader/annotation_hook.py index 2c1a62b85..eeb0cc52c 100644 --- a/src/plugins/rv-packages/otio_reader/annotation_hook.py +++ b/src/plugins/rv-packages/otio_reader/annotation_hook.py @@ -7,6 +7,7 @@ import logging + import effectHook import opentimelineio as otio from rv import commands, extra_commands diff --git a/src/plugins/rv-packages/otio_reader/cdlExportHook.py b/src/plugins/rv-packages/otio_reader/cdlExportHook.py index 43bb96443..95b622b47 100644 --- a/src/plugins/rv-packages/otio_reader/cdlExportHook.py +++ b/src/plugins/rv-packages/otio_reader/cdlExportHook.py @@ -3,8 +3,8 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import commands, extra_commands import opentimelineio as otio +from rv import commands, extra_commands def hook_function(in_timeline, argument_map): @@ -12,13 +12,13 @@ def hook_function(in_timeline, argument_map): if not rv_node_name: return - node_base = "{}.CDL".format(rv_node_name) + node_base = f"{rv_node_name}.CDL" return otio.schemadef.CDL.CDL( name=extra_commands.uiName(rv_node_name), - slope=commands.getFloatProperty("{}.slope".format(node_base)), - power=commands.getFloatProperty("{}.power".format(node_base)), - offset=commands.getFloatProperty("{}.offset".format(node_base)), - saturation=commands.getFloatProperty("{}.saturation".format(node_base))[0], - visible=commands.getIntProperty("{}.active".format(node_base))[0] != 0, + slope=commands.getFloatProperty(f"{node_base}.slope"), + power=commands.getFloatProperty(f"{node_base}.power"), + offset=commands.getFloatProperty(f"{node_base}.offset"), + saturation=commands.getFloatProperty(f"{node_base}.saturation")[0], + visible=commands.getIntProperty(f"{node_base}.active")[0] != 0, ) diff --git a/src/plugins/rv-packages/otio_reader/cdlHook.py b/src/plugins/rv-packages/otio_reader/cdlHook.py index 492b7ade1..9f01c42b4 100644 --- a/src/plugins/rv-packages/otio_reader/cdlHook.py +++ b/src/plugins/rv-packages/otio_reader/cdlHook.py @@ -3,14 +3,14 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import extra_commands, commands -from effectHook import set_rv_effect_props, add_otio_metadata +from effectHook import add_otio_metadata, set_rv_effect_props +from rv import commands, extra_commands def modify_source(source, otio_cdl): rv_cdl = extra_commands.associatedNode("RVLinearize", source) - node_component = "{}.CDL".format(rv_cdl) + node_component = f"{rv_cdl}.CDL" set_rv_effect_props( node_component, { @@ -27,7 +27,7 @@ def modify_source(source, otio_cdl): def add_cdl_node(otio_cdl): rv_cdl = commands.newNode("RVLinearize", otio_cdl.name or "linearize") - node_component = "{}.CDL".format(rv_cdl) + node_component = f"{rv_cdl}.CDL" set_rv_effect_props( node_component, { diff --git a/src/plugins/rv-packages/otio_reader/cdlSchema.py b/src/plugins/rv-packages/otio_reader/cdlSchema.py index 3028c43f1..41b645a90 100644 --- a/src/plugins/rv-packages/otio_reader/cdlSchema.py +++ b/src/plugins/rv-packages/otio_reader/cdlSchema.py @@ -95,33 +95,17 @@ def power(self, val): saturation = otio.core.serializable_field("saturation", required_type=float, doc=("Saturation: expects a float")) def __str__(self): - return 'CDL("{}", "{}", "{}", "{}", "{}", "{}", "{}")'.format( - str(self.name), - str(self.effect_name), - str(self.visible), - str(self.slope), - str(self.offset), - str(self.power), - str(self.saturation), - ) + return f'CDL("{self.name!s}", "{self.effect_name!s}", "{self.visible!s}", "{self.slope!s}", "{self.offset!s}", "{self.power!s}", "{self.saturation!s}")' def __repr__(self): return ( "otio.schema.CDL(" - "name={}, " - "effect_name={}, " - "visible={}, " - "slope={}, " - "offset={}, " - "power={}, " - "saturation={} " - ")".format( - repr(self.name), - repr(self.effect_name), - repr(self.visible), - repr(self.slope), - repr(self.offset), - repr(self.power), - repr(self.saturation), - ) + f"name={self.name!r}, " + f"effect_name={self.effect_name!r}, " + f"visible={self.visible!r}, " + f"slope={self.slope!r}, " + f"offset={self.offset!r}, " + f"power={self.power!r}, " + f"saturation={self.saturation!r} " + ")" ) diff --git a/src/plugins/rv-packages/otio_reader/clipHook.py b/src/plugins/rv-packages/otio_reader/clipHook.py index b2239280a..714854476 100644 --- a/src/plugins/rv-packages/otio_reader/clipHook.py +++ b/src/plugins/rv-packages/otio_reader/clipHook.py @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -from effectHook import * # noqa: F403 +from effectHook import * # this is an example for clip that can be removed or augmented as required diff --git a/src/plugins/rv-packages/otio_reader/effectHook.py b/src/plugins/rv-packages/otio_reader/effectHook.py index d83ed21f4..144422735 100644 --- a/src/plugins/rv-packages/otio_reader/effectHook.py +++ b/src/plugins/rv-packages/otio_reader/effectHook.py @@ -4,8 +4,9 @@ # SPDX-License-Identifier: Apache-2.0 # import sys -from rv import commands + import opentimelineio as otio +from rv import commands SET_NODE_TYPE_MAP = { float: commands.setFloatProperty, @@ -44,7 +45,7 @@ def set_rv_effect_props(node_component, prop_map): """ for prop, value in prop_map.items(): if value is not None: - _set_rv_prop("{}.{}".format(node_component, prop), _get_rv_value(value)) + _set_rv_prop(f"{node_component}.{prop}", _get_rv_value(value)) def add_rv_effect_props(node_component, prop_map): @@ -60,7 +61,7 @@ def add_rv_effect_props(node_component, prop_map): """ for prop, value in prop_map.items(): if value is not None: - prop_name = "{}.{}".format(node_component, prop) + prop_name = f"{node_component}.{prop}" rv_value = _get_rv_value(value) commands.newProperty(prop_name, ADD_NODE_TYPE_MAP[type(rv_value[0])], len(rv_value)) @@ -96,7 +97,7 @@ def get_otio_metadata(node_component): node_component : str The RV node and component containing the metadata """ - metadata_prop = "{}.otio_metadata".format(node_component) + metadata_prop = f"{node_component}.otio_metadata" if commands.propertyExists(metadata_prop): metadata_str = commands.getStringProperty(metadata_prop)[0] return otio.core.deserialize_json_from_string(metadata_str) @@ -115,4 +116,4 @@ def _set_rv_prop(prop_name, value): try: SET_NODE_TYPE_MAP[type(value[0])](prop_name, value, True) except KeyError: - raise NoMappingForRvNode("No RV node found for type {}".format(type(value[0]))) + raise NoMappingForRvNode(f"No RV node found for type {type(value[0])}") diff --git a/src/plugins/rv-packages/otio_reader/genericEffectHook.py b/src/plugins/rv-packages/otio_reader/genericEffectHook.py index a66d469f4..3c4cd792d 100644 --- a/src/plugins/rv-packages/otio_reader/genericEffectHook.py +++ b/src/plugins/rv-packages/otio_reader/genericEffectHook.py @@ -6,4 +6,4 @@ def hook_function(in_timeline, argument_map=None): - print("Warning: Unhandled effect (named {})".format(in_timeline.effect_name)) + print(f"Warning: Unhandled effect (named {in_timeline.effect_name})") diff --git a/src/plugins/rv-packages/otio_reader/multiRepPostExportHook.py b/src/plugins/rv-packages/otio_reader/multiRepPostExportHook.py index 9e81bb291..216856737 100644 --- a/src/plugins/rv-packages/otio_reader/multiRepPostExportHook.py +++ b/src/plugins/rv-packages/otio_reader/multiRepPostExportHook.py @@ -3,8 +3,8 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import commands, extra_commands import opentimelineio as otio +from rv import commands, extra_commands def hook_function(in_timeline, argument_map): @@ -13,7 +13,7 @@ def hook_function(in_timeline, argument_map): # in case there are any post source hooks, run them on the active source for src_group in commands.nodeConnections(switch_node)[0]: source = extra_commands.nodesInGroupOfType(src_group, "RVSource")[0] - if commands.getIntProperty("{}.media.active".format(source))[0] == 1: + if commands.getIntProperty(f"{source}.media.active")[0] == 1: argument_map["rv_node_name"] = src_group otio.hooks.run("post_export_hook_RVSourceGroup", in_timeline, argument_map) diff --git a/src/plugins/rv-packages/otio_reader/otio_reader.py b/src/plugins/rv-packages/otio_reader/otio_reader.py index ce45acfcf..9817d15be 100644 --- a/src/plugins/rv-packages/otio_reader/otio_reader.py +++ b/src/plugins/rv-packages/otio_reader/otio_reader.py @@ -30,13 +30,11 @@ # import logging -from rv import commands -from rv import extra_commands - import os +from contextlib import contextmanager import opentimelineio as otio -from contextlib import contextmanager +from rv import commands, extra_commands @contextmanager @@ -83,7 +81,7 @@ def _run_hook(hook_name, otio_obj, context={}, optional=True): return otio.hooks.run(hook_name, otio_obj, context) except KeyError: if not optional: - raise NoMappingForOtioTypeError(str(type(otio_obj)) + " on object: {}".format(otio_obj)) + raise NoMappingForOtioTypeError(str(type(otio_obj)) + f" on object: {otio_obj}") def create_rv_node_from_otio(otio_obj, context=None): @@ -98,16 +96,16 @@ def create_rv_node_from_otio(otio_obj, context=None): } if type(otio_obj) in WRITE_TYPE_MAP: - process_schema = _run_hook("pre_hook_{}".format(otio_obj.schema_name()), otio_obj, context) + process_schema = _run_hook(f"pre_hook_{otio_obj.schema_name()}", otio_obj, context) if process_schema is False: return None result = WRITE_TYPE_MAP[type(otio_obj)](otio_obj, context) with set_context(context, post_schema=result): - _run_hook("post_hook_{}".format(otio_obj.schema_name()), otio_obj, context) + _run_hook(f"post_hook_{otio_obj.schema_name()}", otio_obj, context) return result - return _run_hook("{}_to_rv".format(otio_obj.schema_name()), otio_obj, context, optional=False) + return _run_hook(f"{otio_obj.schema_name()}_to_rv", otio_obj, context, optional=False) def _retime_trx_input(pre_item, post_item, context=None): @@ -167,7 +165,7 @@ def _create_transition(pre_item, in_trx, post_item, context=None): num_frames = (in_trx.in_offset + in_trx.out_offset).rescaled_to(pre_item.trimmed_range().duration.rate).value - in_offset_prop = "{}.otio.in_offset".format(rv_trx) + in_offset_prop = f"{rv_trx}.otio.in_offset" commands.newProperty(in_offset_prop, commands.IntType, 1) commands.setIntProperty(in_offset_prop, [in_trx.in_offset.to_frames()], True) @@ -205,7 +203,7 @@ def _create_stack(in_stack, context=None): # disable reversed order blending so the top node is on top stack_node = extra_commands.nodesInGroupOfType(new_stack, "RVStack")[0] - commands.setIntProperty("{}.mode.supportReversedOrderBlending".format(stack_node), [0]) + commands.setIntProperty(f"{stack_node}.mode.supportReversedOrderBlending", [0]) return new_stack @@ -261,7 +259,7 @@ def _create_track(in_seq, context=None): _add_metadata_to_node(in_seq, new_seq) # disable reversed order blending so the top node is on top - commands.setIntProperty("{}.mode.supportReversedOrderBlending".format(seq_node), [0]) + commands.setIntProperty(f"{seq_node}.mode.supportReversedOrderBlending", [0]) return new_seq @@ -338,11 +336,11 @@ def _set_sequence_edl(sequence, edl_time, edl): # This effectively forces each cut to use the otio trimmed_range, regardless # of effects or other modifications to a sources timing. - commands.setIntProperty("{}.edl.in".format(sequence), edl["in"]) - commands.setIntProperty("{}.edl.out".format(sequence), edl["out"]) - commands.setIntProperty("{}.edl.frame".format(sequence), edl["frame"]) - commands.setIntProperty("{}.edl.source".format(sequence), list(range(len(edl["frame"])))) - commands.setIntProperty("{}.mode.autoEDL".format(sequence), [0]) + commands.setIntProperty(f"{sequence}.edl.in", edl["in"]) + commands.setIntProperty(f"{sequence}.edl.out", edl["out"]) + commands.setIntProperty(f"{sequence}.edl.frame", edl["frame"]) + commands.setIntProperty(f"{sequence}.edl.source", list(range(len(edl["frame"])))) + commands.setIntProperty(f"{sequence}.mode.autoEDL", [0]) def _get_in_out_frame(it, range_to_read, seq_rate=None): @@ -373,7 +371,7 @@ def _create_timeline(tl, context=None): # also add the timeline name if it has one if tl.name: - name_prop = "{}.otio.timeline_name".format(stack) + name_prop = f"{stack}.otio.timeline_name" commands.newProperty(name_prop, commands.StringType, 1) commands.setStringProperty(name_prop, [tl.name], True) @@ -409,7 +407,7 @@ def _create_media(media_ref, trimmed_range, context=None): elif isinstance(media_ref, otio.schema.ImageSequenceReference): return [ _get_media_path( - str(media_ref.abstract_target_url(symbol="%0{n}d".format(n=media_ref.frame_zero_padding))), + str(media_ref.abstract_target_url(symbol=f"%0{media_ref.frame_zero_padding}d")), context, ) ] @@ -443,7 +441,7 @@ def add_media(media_ref, active_key, cmd, *cmd_args): new_cmd_args = cmd_args + (media,) src = cmd(*new_cmd_args) except Exception as e: - print("ERROR adding media (replacing with smptebars): {}".format(e)) + print(f"ERROR adding media (replacing with smptebars): {e}") error_media = _create_movieproc(item.trimmed_range(), "smptebars") src = commands.addSourceVerbose([error_media]) @@ -483,7 +481,7 @@ def add_media(media_ref, active_key, cmd, *cmd_args): switch_group = commands.nodeConnections(source_group)[1][0] switch = extra_commands.nodesInGroupOfType(switch_group, "RVSwitch")[0] - commands.setIntProperty("{}.mode.autoEDL".format(switch), [0]) + commands.setIntProperty(f"{switch}.mode.autoEDL", [0]) return switch_group, active_source @@ -530,7 +528,7 @@ def _create_item(it, context=None): range_to_read = it.trimmed_range() if not range_to_read: - raise otio.exceptions.OTIOError("No valid range on clip: {0}.".format(str(it))) + raise otio.exceptions.OTIOError(f"No valid range on clip: {it!s}.") src_or_switch_group, active_src = _create_sources(it, context) _add_metadata_to_node(it, src_or_switch_group) @@ -550,12 +548,7 @@ def _create_item(it, context=None): def _create_movieproc(time_range, kind="blank"): - movieproc = "{},start={},end={},fps={}.movieproc".format( - kind, - time_range.start_time.value, - time_range.end_time_inclusive().value, - time_range.duration.rate, - ) + movieproc = f"{kind},start={time_range.start_time.value},end={time_range.end_time_inclusive().value},fps={time_range.duration.rate}.movieproc" return movieproc @@ -585,16 +578,16 @@ def _add_markers(it, node): if frames: ins, outs = map(list, zip(*frames)) - commands.setStringProperty("{}.markers.name".format(node), names, True) - commands.setIntProperty("{}.markers.in".format(node), ins, True) - commands.setIntProperty("{}.markers.out".format(node), outs, True) + commands.setStringProperty(f"{node}.markers.name", names, True) + commands.setIntProperty(f"{node}.markers.in", ins, True) + commands.setIntProperty(f"{node}.markers.out", outs, True) commands.setFloatProperty( - "{}.markers.color".format(node), + f"{node}.markers.color", [color for rgba in colors for color in rgba], True, ) - commands.newProperty("{}.markers.otio_metadata".format(node), commands.StringType, 1) - commands.setStringProperty("{}.markers.otio_metadata".format(node), metadata, True) + commands.newProperty(f"{node}.markers.otio_metadata", commands.StringType, 1) + commands.setStringProperty(f"{node}.markers.otio_metadata", metadata, True) def _get_color_from_name(name, defaultColor="PURPLE"): @@ -651,20 +644,20 @@ def _add_source_bounds(media_ref, src, active_src, context=None): transform_node = extra_commands.associatedNode("RVTransform2D", src) - commands.setFloatProperty("{}.transform.scale".format(transform_node), [scale.x / aspect_ratio, scale.y]) - commands.setFloatProperty("{}.transform.translate".format(transform_node), [translate.x, translate.y]) + commands.setFloatProperty(f"{transform_node}.transform.scale", [scale.x / aspect_ratio, scale.y]) + commands.setFloatProperty(f"{transform_node}.transform.translate", [translate.x, translate.y]) # write the bounds global_scale and global_translate to the node so we can # preserve the original values if we round-trip - commands.newProperty("{}.otio.global_scale".format(transform_node), commands.FloatType, 2) - commands.newProperty("{}.otio.global_translate".format(transform_node), commands.FloatType, 2) + commands.newProperty(f"{transform_node}.otio.global_scale", commands.FloatType, 2) + commands.newProperty(f"{transform_node}.otio.global_translate", commands.FloatType, 2) commands.setFloatProperty( - "{}.otio.global_scale".format(transform_node), + f"{transform_node}.otio.global_scale", [global_scale.x, global_scale.y], True, ) commands.setFloatProperty( - "{}.otio.global_translate".format(transform_node), + f"{transform_node}.otio.global_translate", [global_translate.x, global_translate.y], True, ) @@ -675,7 +668,7 @@ def _add_metadata_to_node(item, rv_node, prop_name="metadata"): Add metadata from otio "item" to rv_node """ if item.metadata: - otio_metadata_property = "{}.otio.{}".format(rv_node, prop_name) + otio_metadata_property = f"{rv_node}.otio.{prop_name}" otio_metadata = otio.core.serialize_json_to_string(item.metadata, indent=-1) commands.newProperty(otio_metadata_property, commands.StringType, 1) commands.setStringProperty(otio_metadata_property, [otio_metadata], True) diff --git a/src/plugins/rv-packages/otio_reader/otio_reader_plugin.py b/src/plugins/rv-packages/otio_reader/otio_reader_plugin.py index 93532e6a9..18d0b2b84 100644 --- a/src/plugins/rv-packages/otio_reader/otio_reader_plugin.py +++ b/src/plugins/rv-packages/otio_reader/otio_reader_plugin.py @@ -25,21 +25,16 @@ # language governing permissions and limitations under the Apache License. # -from __future__ import print_function - import os import sys -from rv import commands, extra_commands -from rv import rvtypes - import opentimelineio as otio - import otio_reader import otio_writer +from rv import commands, extra_commands, rvtypes -class Mode(object): +class Mode: sleeping = 1 loading = 2 processing = 3 @@ -47,7 +42,7 @@ class Mode(object): class ExampleOTIOReaderPlugin(rvtypes.MinorMode): def __init__(self): - super(ExampleOTIOReaderPlugin, self).__init__() + super().__init__() self.init( "example_otio_reader", [ @@ -100,7 +95,7 @@ def incoming_source_path(self, event): if ext in otio.adapters.suffixes_with_defined_adapters(read=True): self.mode = Mode.loading - movieproc = "blank,otioFile={}.movieproc".format(in_path) + movieproc = f"blank,otioFile={in_path}.movieproc" event.setReturnContent(movieproc) def after_progressive_loading(self, event): @@ -193,7 +188,7 @@ def expand_sources(self): commands.setViewNode(result) break except Exception as e: - message = "ERROR: {}".format(e) + message = f"ERROR: {e}" extra_commands.displayFeedback(message, 5.0) print(message, file=sys.stderr) raise e diff --git a/src/plugins/rv-packages/otio_reader/otio_writer.py b/src/plugins/rv-packages/otio_reader/otio_writer.py index 61f7ccae7..82384d027 100644 --- a/src/plugins/rv-packages/otio_reader/otio_writer.py +++ b/src/plugins/rv-packages/otio_reader/otio_writer.py @@ -5,15 +5,12 @@ # import math import numbers -import six import os import re import opentimelineio as otio - -from rv import commands -from rv import extra_commands -from rv import runtime +import six +from rv import commands, extra_commands, runtime class NoMappingForNodeTypeError(otio.exceptions.OTIOError): @@ -59,7 +56,7 @@ def create_timeline_from_node(root_node_name): if commands.nodeType(root_node_name) == "RVStackGroup": # check if the OTIO import saved any timeline properties to the stack timeline.metadata.update(get_node_otio_metadata(root_node_name, "timeline_metadata")) - name_prop = "{}.otio.timeline_name".format(root_node_name) + name_prop = f"{root_node_name}.otio.timeline_name" if commands.propertyExists(name_prop): timeline.name = commands.getStringProperty(name_prop)[0] @@ -87,7 +84,7 @@ def _run_hook(hook_name, optional=True, *args, **kwargs): return otio.hooks.run(hook_name, kwargs.get("timeline"), kwargs) except KeyError: if not optional: - raise NoMappingForNodeTypeError("No {} hook found".format(hook_name)) + raise NoMappingForNodeTypeError(f"No {hook_name} hook found") def create_otio_from_rv_node(node_name, *args, **kwargs): @@ -107,15 +104,13 @@ def create_otio_from_rv_node(node_name, *args, **kwargs): node_type = commands.nodeType(node_name) if node_type in create_type_map: - process_node = _run_hook( - "pre_export_hook_{}".format(node_type), rv_node_name=node_name, optional=True, *args, **kwargs - ) + process_node = _run_hook(f"pre_export_hook_{node_type}", rv_node_name=node_name, optional=True, *args, **kwargs) if process_node is False: return None result = create_type_map[node_type](node_name, *args, **kwargs) _run_hook( - "post_export_hook_{}".format(node_type), + f"post_export_hook_{node_type}", rv_node_name=node_name, post_node=result, optional=True, @@ -123,7 +118,7 @@ def create_otio_from_rv_node(node_name, *args, **kwargs): **kwargs, ) else: - result = _run_hook("export_{}".format(node_type), rv_node_name=node_name, optional=False, *args, **kwargs) + result = _run_hook(f"export_{node_type}", rv_node_name=node_name, optional=False, *args, **kwargs) if not isinstance(result, otio.schema.Effect): return result @@ -134,7 +129,7 @@ def create_otio_from_rv_node(node_name, *args, **kwargs): # Each effect should have one input (another effect or something that # results in an otio item). If not, we don't know how to handle it if num_effect_inputs != 1: - raise UnhandledEffectInput("{} effect ({}) should have 1 input".format(node_type, node_name)) + raise UnhandledEffectInput(f"{node_type} effect ({node_name}) should have 1 input") # Since we are iterate through inputs, we will find effects before we find # the items they belong to. So recurse, keeping track of the effects we've @@ -265,9 +260,9 @@ def _create_item(node_name, *args, **kwargs): for src_group in commands.nodeConnections(node_name)[0]: source = get_source_node(src_group) - key = commands.getStringProperty("{}.media.repName".format(source))[0] + key = commands.getStringProperty(f"{source}.media.repName")[0] - if commands.getIntProperty("{}.media.active".format(source))[0] == 1: + if commands.getIntProperty(f"{source}.media.active")[0] == 1: active_key = key active_source = source active_source_group = src_group @@ -400,7 +395,7 @@ def _create_transition(rv_trx, *args, **kwargs): # If we imported from OTIO, respect the original in_offset. If not, # assume the transition frames are split evenly between the two clips - in_offset_prop = "{}.otio.in_offset".format(rv_trx) + in_offset_prop = f"{rv_trx}.otio.in_offset" if commands.propertyExists(in_offset_prop): in_offset_frames = commands.getIntProperty(in_offset_prop)[0] @@ -504,7 +499,7 @@ def get_node_otio_metadata(node_name, prop_name="metadata"): :return: `str` """ # Standard OTIO Metadata prop from OTIO Reader - otio_prop = "{}.otio.{}".format(node_name, prop_name) + otio_prop = f"{node_name}.otio.{prop_name}" # Persist the general OTIO metadata separately to match OTIO Reader if commands.propertyExists(otio_prop): @@ -582,7 +577,7 @@ def is_same_media(node_name, item): return get_source_path(node_name) == item.media_reference.target_url elif isinstance(item.media_reference, otio.schema.ImageSequenceReference): return get_source_path(node_name) == item.media_reference_abstract_target_url( - symbol="%0{n}d".format(n=item.media_reference.frame_zero_padding) + symbol=f"%0{item.media_reference.frame_zero_padding}d" ) elif isinstance(item.media_reference, otio.schema.GeneratorReference): if get_source_path(node_name).startswith("smptebars,"): diff --git a/src/plugins/rv-packages/otio_reader/retimeExportHook.py b/src/plugins/rv-packages/otio_reader/retimeExportHook.py index 5786b631d..35e4ac520 100644 --- a/src/plugins/rv-packages/otio_reader/retimeExportHook.py +++ b/src/plugins/rv-packages/otio_reader/retimeExportHook.py @@ -3,13 +3,13 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import commands, extra_commands -import opentimelineio as otio - -import six import math import sys +import opentimelineio as otio +import six +from rv import commands, extra_commands + def hook_function(in_timeline, argument_map): def is_close(v1, v2, rel_tol=1e-05, abs_tol=0.0): @@ -21,12 +21,12 @@ def is_close(v1, v2, rel_tol=1e-05, abs_tol=0.0): if not rv_node_name: return - scalar = 1 / commands.getFloatProperty("{}.audio.scale".format(rv_node_name))[0] + scalar = 1 / commands.getFloatProperty(f"{rv_node_name}.audio.scale")[0] if is_close(scalar, 1.0): - scalar = 1 / commands.getFloatProperty("{}.visual.scale".format(rv_node_name))[0] + scalar = 1 / commands.getFloatProperty(f"{rv_node_name}.visual.scale")[0] - key_frames = commands.getIntProperty("{}.warp.keyFrames".format(rv_node_name)) + key_frames = commands.getIntProperty(f"{rv_node_name}.warp.keyFrames") # only linear warps are supported if len(key_frames) > 1: diff --git a/src/plugins/rv-packages/otio_reader/sourcePostExportHook.py b/src/plugins/rv-packages/otio_reader/sourcePostExportHook.py index 79b404836..5c8177747 100644 --- a/src/plugins/rv-packages/otio_reader/sourcePostExportHook.py +++ b/src/plugins/rv-packages/otio_reader/sourcePostExportHook.py @@ -3,9 +3,9 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import commands, extra_commands -from effectHook import get_otio_metadata import opentimelineio as otio +from effectHook import get_otio_metadata +from rv import commands, extra_commands def hook_function(in_timeline, argument_map): @@ -40,23 +40,23 @@ def hook_function(in_timeline, argument_map): # for releases >= 0.15 if hasattr(clip.media_reference, "available_image_bounds"): transform = extra_commands.associatedNode("RVTransform2D", source) - if commands.getIntProperty("{}.transform.active".format(transform))[0] != 0: + if commands.getIntProperty(f"{transform}.transform.active")[0] != 0: global_translate_vec = otio.schema.V2d(0.0, 0.0) global_scale_vec = otio.schema.V2d(1.0, 1.0) - if commands.propertyExists("{}.otio.global_translate".format(transform)) and commands.propertyExists( - "{}.otio.global_scale".format(transform) + if commands.propertyExists(f"{transform}.otio.global_translate") and commands.propertyExists( + f"{transform}.otio.global_scale" ): - global_translate = commands.getFloatProperty("{}.otio.global_translate".format(transform)) - global_scale = commands.getFloatProperty("{}.otio.global_scale".format(transform)) + global_translate = commands.getFloatProperty(f"{transform}.otio.global_translate") + global_scale = commands.getFloatProperty(f"{transform}.otio.global_scale") global_translate_vec = otio.schema.V2d(global_translate[0], global_translate[1]) global_scale_vec = otio.schema.V2d(global_scale[0], global_scale[1]) translate = commands.getFloatProperty( - "{}.transform.translate".format(transform), + f"{transform}.transform.translate", ) scale = commands.getFloatProperty( - "{}.transform.scale".format(transform), + f"{transform}.transform.scale", ) translate_vec = otio.schema.V2d(translate[0], translate[1]) diff --git a/src/plugins/rv-packages/otio_reader/timeWarpHook.py b/src/plugins/rv-packages/otio_reader/timeWarpHook.py index 26d133d08..43471f754 100644 --- a/src/plugins/rv-packages/otio_reader/timeWarpHook.py +++ b/src/plugins/rv-packages/otio_reader/timeWarpHook.py @@ -5,8 +5,8 @@ # import sys -from rv import commands from effectHook import set_rv_effect_props +from rv import commands def hook_function(in_timeline, argument_map=None): @@ -18,6 +18,6 @@ def hook_function(in_timeline, argument_map=None): kind = "audio" if argument_map.get("kind", "") == "Audio" else "visual" - node_component = "{}.{}".format(rv_retime, kind) + node_component = f"{rv_retime}.{kind}" set_rv_effect_props(node_component, {"scale": 1 / scalar}) return rv_retime diff --git a/src/plugins/rv-packages/pyhello/pyhello.py b/src/plugins/rv-packages/pyhello/pyhello.py index 7c84b1829..3e1506580 100644 --- a/src/plugins/rv-packages/pyhello/pyhello.py +++ b/src/plugins/rv-packages/pyhello/pyhello.py @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes, commands +from rv import commands, rvtypes class PyHello(rvtypes.MinorMode): diff --git a/src/plugins/rv-packages/pymystuff/pymystuff.py b/src/plugins/rv-packages/pymystuff/pymystuff.py index 0af3cadfd..1c1caf000 100644 --- a/src/plugins/rv-packages/pymystuff/pymystuff.py +++ b/src/plugins/rv-packages/pymystuff/pymystuff.py @@ -3,9 +3,8 @@ # # SPDX-License-Identifier: Apache-2.0 # +from rv import commands, extra_commands from rv.rvtypes import MinorMode -import rv.commands as commands -import rv.extra_commands as extra_commands class PyMyStuffMode(MinorMode): diff --git a/src/plugins/rv-packages/pyside_example/pyside_example.py b/src/plugins/rv-packages/pyside_example/pyside_example.py index 05f337fbc..3cae76b0a 100755 --- a/src/plugins/rv-packages/pyside_example/pyside_example.py +++ b/src/plugins/rv-packages/pyside_example/pyside_example.py @@ -6,28 +6,27 @@ import os try: - from PySide2 import QtGui, QtCore, QtWidgets - from PySide2.QtGui import * + from PySide2 import QtCore, QtGui, QtWidgets from PySide2.QtCore import * - from PySide2.QtWidgets import * + from PySide2.QtGui import * from PySide2.QtUiTools import QUiLoader + from PySide2.QtWidgets import * except ImportError: try: - from PySide6 import QtGui, QtCore, QtWidgets - from PySide6.QtGui import * + from PySide6 import QtCore, QtGui, QtWidgets from PySide6.QtCore import * - from PySide6.QtWidgets import * + from PySide6.QtGui import * from PySide6.QtUiTools import QUiLoader + from PySide6.QtWidgets import * except ImportError: pass -from OpenGL.GL import * -from OpenGL.GLUT import * -from OpenGL.GLU import * +import pyside_example # need to get at the module itself import rv import rv.qtutils - -import pyside_example # need to get at the module itself +from OpenGL.GL import * +from OpenGL.GLU import * +from OpenGL.GLUT import * class PySideDockTest(rv.rvtypes.MinorMode): @@ -121,10 +120,8 @@ def F(value): try: p = rv.commands.getFloatProperty(prop, 0, 1231231) p[0] += diff - if p[0] > spins[index].maximum(): - p[0] = spins[index].maximum() - if p[0] < spins[index].minimum(): - p[0] = spins[index].minimum() + p[0] = min(p[0], spins[index].maximum()) + p[0] = max(p[0], spins[index].minimum()) spins[index].setValue(p[0]) rv.commands.setFloatProperty(prop, p, True) except Exception: @@ -158,7 +155,7 @@ def findSet(self, typeObj, names): def hookup(self, checkbox, spins, dials, prop, last): checkbox.released.connect(self.checkBoxPressed(checkbox, "%s.node.active" % prop)) - for i in range(0, 3): + for i in range(3): dial = dials[i] spin = spins[i] propName = "%s.warp.k%d" % (prop, i + 1) diff --git a/src/plugins/rv-packages/rvnuke/menu.py b/src/plugins/rv-packages/rvnuke/menu.py index 1d236b6c3..0a0346821 100644 --- a/src/plugins/rv-packages/rvnuke/menu.py +++ b/src/plugins/rv-packages/rvnuke/menu.py @@ -1,5 +1,5 @@ -import rvNuke import nuke +import rvNuke menubar = nuke.menu("Nuke") diff --git a/src/plugins/rv-packages/rvnuke/rvNetwork.py b/src/plugins/rv-packages/rvnuke/rvNetwork.py index eb5cf6cdf..f5bfc93ee 100755 --- a/src/plugins/rv-packages/rvnuke/rvNetwork.py +++ b/src/plugins/rv-packages/rvnuke/rvNetwork.py @@ -4,12 +4,11 @@ # SPDX-License-Identifier: Apache-2.0 # #! /usr/bin/python -from __future__ import print_function +import os import socket import sys import time -import os doDebug = False if os.getenv("RV_NUKE_DEBUG") is not None: @@ -62,13 +61,13 @@ def connect(self, host, port=-1): try: self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - except socket.error as msg: + except OSError as msg: print("ERROR: can't create socket: %s\n" % msg[1], file=sys.stderr) return try: self.sock.connect((host, self.port)) - except socket.error as msg: + except OSError as msg: print("ERROR: can't connect: %s\n" % msg[1], file=sys.stderr) return @@ -77,7 +76,7 @@ def connect(self, host, port=-1): self.sock.sendall(b"NEWGREETING %d %s" % (len(greeting), greeting.encode("utf-8"))) if self.noPingPong: self.sock.sendall(b"PINGPONGCONTROL 1 0") - except socket.error as msg: + except OSError as msg: print("ERROR: can't send greeting: %s\n" % msg[1], file=sys.stderr) return @@ -146,7 +145,7 @@ def messageAvailable(self): self.sock.close() self.connected = False - except socket.error as msg: + except OSError as msg: if ( msg.strerror != "Resource temporarily unavailable" and msg.strerror != "A non-blocking socket operation could not be completed immediately" @@ -182,7 +181,7 @@ def _receiveSingleMessage(self): messContents = self.sock.recv(messSize) self.sock.setblocking(0) - except socket.error as msg: + except OSError as msg: print("ERROR: can't process message: %s\n" % msg[1], file=sys.stderr) self.sock.setblocking(0) diff --git a/src/plugins/rv-packages/rvnuke/rvNuke.py b/src/plugins/rv-packages/rvnuke/rvNuke.py index 71dccbcf5..e85c01e29 100644 --- a/src/plugins/rv-packages/rvnuke/rvNuke.py +++ b/src/plugins/rv-packages/rvnuke/rvNuke.py @@ -3,19 +3,19 @@ # # SPDX-License-Identifier: Apache-2.0 # -from __future__ import print_function -import nuke -import nukescripts import os -import re import platform +import re +import select import subprocess -import rvNetwork -import time import sys -import select import threading +import time + +import nuke +import nukescripts +import rvNetwork protocolVersion = 115 diff --git a/src/plugins/rv-packages/session_manager/local_thumbnail_gen.py b/src/plugins/rv-packages/session_manager/local_thumbnail_gen.py index 49594b4ba..cd9426897 100644 --- a/src/plugins/rv-packages/session_manager/local_thumbnail_gen.py +++ b/src/plugins/rv-packages/session_manager/local_thumbnail_gen.py @@ -2,7 +2,6 @@ import logging import math import os -import psutil import shutil import subprocess import sys @@ -14,6 +13,8 @@ from pathlib import Path from typing import Any +import psutil + try: from PySide2 import QtCore except ImportError: diff --git a/src/plugins/rv-packages/source_setup/source_setup.py b/src/plugins/rv-packages/source_setup/source_setup.py index 49d096e55..ade4767fd 100755 --- a/src/plugins/rv-packages/source_setup/source_setup.py +++ b/src/plugins/rv-packages/source_setup/source_setup.py @@ -3,13 +3,11 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes -from rv import commands -from rv import extra_commands - import os -import re import platform +import re + +from rv import commands, extra_commands, rvtypes from six.moves.urllib.parse import urlparse @@ -110,7 +108,7 @@ def sourceSetup(self, event, noColorChanges=False): return if srcAttrs is None: - print(("ERROR: SourceSetup: source %s/%s has no attributes" % (source, fileName))) + print("ERROR: SourceSetup: source %s/%s has no attributes" % (source, fileName)) return attrDict = dict(zip([i[0] for i in srcAttrs], [j[1] for j in srcAttrs])) @@ -131,7 +129,7 @@ def sourceSetup(self, event, noColorChanges=False): "EXIF/Gamma": "EXIFGamma", "ARRI-Image/DataSpace": "ARRIDataSpace", } - for key in attrMap.keys(): + for key in attrMap: try: srcInfo[attrMap[key]] = attrDict[key] except KeyError: @@ -140,7 +138,7 @@ def sourceSetup(self, event, noColorChanges=False): if len(srcData) > 0: dataDict = dict(zip([i[0] for i in srcData], [j[1] for j in srcData])) dataMap = {"ColorSpace/ICC/Data": "ICCProfileData"} - for key in dataMap.keys(): + for key in dataMap: try: srcInfo[dataMap[key]] = dataDict[key] except KeyError: @@ -252,7 +250,7 @@ def sourceSetup(self, event, noColorChanges=False): # Get around maya bugs # - print(("WARNING: Assuming %s was created by Maya with a bad pixel aspect ratio\n" % fileName)) + print("WARNING: Assuming %s was created by Maya with a bad pixel aspect ratio\n" % fileName) self.setPixelAspect(lensNode, 1.0) if srcInfo["JPEGPixelAspect"] != "" and srcInfo["JPEGDensity"] != "": @@ -266,7 +264,7 @@ def sourceSetup(self, event, noColorChanges=False): # Maya JPEG -- fix pixel aspect # - print(("WARNING: Assuming %s was created by Maya with a bad pixel aspect ratio\n" % fileName)) + print("WARNING: Assuming %s was created by Maya with a bad pixel aspect ratio\n" % fileName) self.setPixelAspect(lensNode, 1.0) # @@ -421,7 +419,7 @@ def setFileColorSpace(self, node, tf, cs): elif tf == "" and cs != "Linear": tolinear = False else: - print(("WARNING: Unknown TransferFunction '%s'" % tf)) + print("WARNING: Unknown TransferFunction '%s'" % tf) commands.setIntProperty(node + ".color.sRGB2linear", [sRGB], True) commands.setIntProperty(node + ".color.logtype", [logT], True) diff --git a/src/plugins/rv-packages/stereo_autoload/stereo_autoload.py b/src/plugins/rv-packages/stereo_autoload/stereo_autoload.py index 1dac0af10..08d43909f 100644 --- a/src/plugins/rv-packages/stereo_autoload/stereo_autoload.py +++ b/src/plugins/rv-packages/stereo_autoload/stereo_autoload.py @@ -3,13 +3,12 @@ # # SPDX-License-Identifier: Apache-2.0 # -from __future__ import print_function - -from rv import commands, extra_commands, rvtypes import os -import sys import re +import sys + +from rv import commands, extra_commands, rvtypes def deb(s): diff --git a/src/plugins/rv-packages/stereo_disassembly/stereo_disassembly.py b/src/plugins/rv-packages/stereo_disassembly/stereo_disassembly.py index a8215c045..58893dc06 100644 --- a/src/plugins/rv-packages/stereo_disassembly/stereo_disassembly.py +++ b/src/plugins/rv-packages/stereo_disassembly/stereo_disassembly.py @@ -3,16 +3,14 @@ # # SPDX-License-Identifier: Apache-2.0 # -from __future__ import print_function + +import sys from rv import commands as rvc from rv import extra_commands as rve from rv import rvtypes as rvt -import sys - - def deb(s): if False: print("stereoDis: " + s + "\n", file=sys.stderr) diff --git a/src/plugins/rv-packages/webview2/webview2.py b/src/plugins/rv-packages/webview2/webview2.py index 354ef7ea7..0b79ada7c 100644 --- a/src/plugins/rv-packages/webview2/webview2.py +++ b/src/plugins/rv-packages/webview2/webview2.py @@ -4,36 +4,24 @@ # SPDX-License-Identifier: Apache-2.0 # -import sys import os +import sys - -from rv import rvtypes -from rv import qtutils +from rv import qtutils, rvtypes try: - from PySide2 import QtCore - from PySide2 import QtWidgets - from PySide2 import QtWebChannel - from PySide2 import QtWebEngineWidgets - from PySide2 import QtQml - + from PySide2 import QtCore, QtQml, QtWebChannel, QtWebEngineWidgets, QtWidgets from PySide2.QtWidgets import ( + QDockWidget, qApp, ) # import qApp#, QMainWindow, QLabel, QPixmap, QColor, QGridLayout, QWidget, QPushButton, QComboBox - from PySide2.QtWidgets import QDockWidget except ImportError: try: - from PySide6 import QtCore - from PySide6 import QtWidgets - from PySide6 import QtWebChannel - from PySide6 import QtWebEngineWidgets - from PySide6 import QtQml - + from PySide6 import QtCore, QtQml, QtWebChannel, QtWebEngineWidgets, QtWidgets from PySide6.QtWidgets import ( + QDockWidget, qApp, ) # import qApp#, QMainWindow, QLabel, QPixmap, QColor, QGridLayout, QWidget, QPushButton, QComboBox - from PySide6.QtWidgets import QDockWidget except ImportError: pass