From 92d751d94dfc6f4dfd7115fb2e358df380eecfa0 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Thu, 3 Dec 2020 16:04:52 +0100 Subject: [PATCH] replace project_settings with get_project_settings --- .ropeproject/config.py | 114 ++++++++++++++++++ pype/__init__.py | 4 +- pype/lib/avalon_context.py | 4 +- pype/lib/plugin_tools.py | 4 +- .../action_create_project_structure.py | 6 +- .../ftrack/events/event_user_assigment.py | 6 +- .../events/event_version_to_task_statuses.py | 6 +- pype/plugin.py | 4 +- .../plugins/maya/create/create_rendersetup.py | 4 +- pype/plugins/maya/load/load_ass.py | 6 +- pype/plugins/maya/load/load_gpucache.py | 4 +- pype/plugins/maya/load/load_reference.py | 4 +- .../plugins/maya/load/load_vdb_to_redshift.py | 4 +- pype/plugins/maya/load/load_vdb_to_vray.py | 4 +- pype/plugins/maya/load/load_vrayproxy.py | 4 +- pype/plugins/maya/load/load_yeti_cache.py | 4 +- pype/plugins/maya/load/load_yeti_rig.py | 4 +- pype/plugins/nuke/load/load_mov.py | 4 +- pype/tools/pyblish_pype/control.py | 4 +- .../widgets/widget_family.py | 4 +- setup/maya/userSetup.py | 4 +- 21 files changed, 158 insertions(+), 44 deletions(-) create mode 100644 .ropeproject/config.py diff --git a/.ropeproject/config.py b/.ropeproject/config.py new file mode 100644 index 0000000000..dee2d1ae9a --- /dev/null +++ b/.ropeproject/config.py @@ -0,0 +1,114 @@ +# The default ``config.py`` +# flake8: noqa + + +def set_prefs(prefs): + """This function is called before opening the project""" + + # Specify which files and folders to ignore in the project. + # Changes to ignored resources are not added to the history and + # VCSs. Also they are not returned in `Project.get_files()`. + # Note that ``?`` and ``*`` match all characters but slashes. + # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' + # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' + # '.svn': matches 'pkg/.svn' and all of its children + # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' + # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' + prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject', + '.hg', '.svn', '_svn', '.git', '.tox'] + + # Specifies which files should be considered python files. It is + # useful when you have scripts inside your project. Only files + # ending with ``.py`` are considered to be python files by + # default. + # prefs['python_files'] = ['*.py'] + + # Custom source folders: By default rope searches the project + # for finding source folders (folders that should be searched + # for finding modules). You can add paths to that list. Note + # that rope guesses project source folders correctly most of the + # time; use this if you have any problems. + # The folders should be relative to project root and use '/' for + # separating folders regardless of the platform rope is running on. + # 'src/my_source_folder' for instance. + # prefs.add('source_folders', 'src') + + # You can extend python path for looking up modules + # prefs.add('python_path', '~/python/') + + # Should rope save object information or not. + prefs['save_objectdb'] = True + prefs['compress_objectdb'] = False + + # If `True`, rope analyzes each module when it is being saved. + prefs['automatic_soa'] = True + # The depth of calls to follow in static object analysis + prefs['soa_followed_calls'] = 0 + + # If `False` when running modules or unit tests "dynamic object + # analysis" is turned off. This makes them much faster. + prefs['perform_doa'] = True + + # Rope can check the validity of its object DB when running. + prefs['validate_objectdb'] = True + + # How many undos to hold? + prefs['max_history_items'] = 32 + + # Shows whether to save history across sessions. + prefs['save_history'] = True + prefs['compress_history'] = False + + # Set the number spaces used for indenting. According to + # :PEP:`8`, it is best to use 4 spaces. Since most of rope's + # unit-tests use 4 spaces it is more reliable, too. + prefs['indent_size'] = 4 + + # Builtin and c-extension modules that are allowed to be imported + # and inspected by rope. + prefs['extension_modules'] = [] + + # Add all standard c-extensions to extension_modules list. + prefs['import_dynload_stdmods'] = True + + # If `True` modules with syntax errors are considered to be empty. + # The default value is `False`; When `False` syntax errors raise + # `rope.base.exceptions.ModuleSyntaxError` exception. + prefs['ignore_syntax_errors'] = False + + # If `True`, rope ignores unresolvable imports. Otherwise, they + # appear in the importing namespace. + prefs['ignore_bad_imports'] = False + + # If `True`, rope will insert new module imports as + # `from import ` by default. + prefs['prefer_module_from_imports'] = False + + # If `True`, rope will transform a comma list of imports into + # multiple separate import statements when organizing + # imports. + prefs['split_imports'] = False + + # If `True`, rope will remove all top-level import statements and + # reinsert them at the top of the module when making changes. + prefs['pull_imports_to_top'] = True + + # If `True`, rope will sort imports alphabetically by module name instead + # of alphabetically by import statement, with from imports after normal + # imports. + prefs['sort_imports_alphabetically'] = False + + # Location of implementation of + # rope.base.oi.type_hinting.interfaces.ITypeHintingFactory In general + # case, you don't have to change this value, unless you're an rope expert. + # Change this value to inject you own implementations of interfaces + # listed in module rope.base.oi.type_hinting.providers.interfaces + # For example, you can add you own providers for Django Models, or disable + # the search type-hinting in a class hierarchy, etc. + prefs['type_hinting_factory'] = ( + 'rope.base.oi.type_hinting.factory.default_type_hinting_factory') + + +def project_opened(project): + """This function is called after opening the project""" + # Do whatever you like here! diff --git a/pype/__init__.py b/pype/__init__.py index 928bff6e9d..8481fa2d48 100644 --- a/pype/__init__.py +++ b/pype/__init__.py @@ -2,7 +2,7 @@ import os from pyblish import api as pyblish from avalon import api as avalon -from .api import project_settings, Anatomy +from .api import get_project_settings, Anatomy from .lib import filter_pyblish_plugins @@ -50,7 +50,7 @@ def patched_discover(superclass): print(">>> trying to find presets for {}:{} ...".format(host, plugin_type)) try: - settings = project_settings(os.environ['AVALON_PROJECT'])[host][plugin_type] + settings = get_project_settings(os.environ['AVALON_PROJECT'])[host][plugin_type] except KeyError: print("*** no presets found.") else: diff --git a/pype/lib/avalon_context.py b/pype/lib/avalon_context.py index c984e47b91..25966d550e 100644 --- a/pype/lib/avalon_context.py +++ b/pype/lib/avalon_context.py @@ -5,7 +5,7 @@ import logging import collections from avalon import io, pipeline -from ..api import project_settings +from ..api import get_project_settings import avalon.api log = logging.getLogger("AvalonContext") @@ -410,7 +410,7 @@ class BuildWorkfile: (dict): preset per entered task name """ host_name = avalon.api.registered_host().__name__.rsplit(".", 1)[-1] - presets = project_settings(io.Session["AVALON_PROJECT"]) + presets = get_project_settings(io.Session["AVALON_PROJECT"]) # Get presets for host build_presets = ( presets.get(host_name, {}) diff --git a/pype/lib/plugin_tools.py b/pype/lib/plugin_tools.py index 185ebce10f..726726bb4c 100644 --- a/pype/lib/plugin_tools.py +++ b/pype/lib/plugin_tools.py @@ -4,7 +4,7 @@ import os import inspect import logging -from ..api import config, project_settings +from ..api import config, get_project_settings log = logging.getLogger(__name__) @@ -25,7 +25,7 @@ def filter_pyblish_plugins(plugins): host = api.current_host() - presets = project_settings(os.environ['AVALON_PROJECT']) or {} + presets = get_project_settings(os.environ['AVALON_PROJECT']) or {} # iterate over plugins for plugin in plugins[:]: diff --git a/pype/modules/ftrack/actions/action_create_project_structure.py b/pype/modules/ftrack/actions/action_create_project_structure.py index d5cb381a63..4fc59da89e 100644 --- a/pype/modules/ftrack/actions/action_create_project_structure.py +++ b/pype/modules/ftrack/actions/action_create_project_structure.py @@ -2,7 +2,7 @@ import os import re from pype.modules.ftrack.lib import BaseAction, statics_icon -from pype.api import Anatomy, project_settings as get_project_settings +from pype.api import Anatomy, get_project_settings as get_project_settings class CreateProjectFolders(BaseAction): @@ -73,9 +73,9 @@ class CreateProjectFolders(BaseAction): project_entity = self.get_project_from_entity(entities[0]) # Load settings for project project_name = project_entity["full_name"] - project_settings = get_project_settings(project_name) + get_project_settings = get_project_settings(project_name) project_folder_structure = ( - project_settings["global"]["project_folder_structure"] + get_project_settings["global"]["project_folder_structure"] ) if not project_folder_structure: return { diff --git a/pype/modules/ftrack/events/event_user_assigment.py b/pype/modules/ftrack/events/event_user_assigment.py index bc05faa192..6a230f6ff9 100644 --- a/pype/modules/ftrack/events/event_user_assigment.py +++ b/pype/modules/ftrack/events/event_user_assigment.py @@ -8,7 +8,7 @@ from avalon.api import AvalonMongoDB from bson.objectid import ObjectId -from pype.api import Anatomy, project_settings as get_project_settings +from pype.api import Anatomy, get_project_settings as get_project_settings class UserAssigmentEvent(BaseEvent): @@ -200,9 +200,9 @@ class UserAssigmentEvent(BaseEvent): project_name = task_entity["project"]["full_name"] project_data = tmp_by_project_name.get(project_name) or {} if "scripts_by_action" not in project_data: - project_settings = get_project_settings(project_name) + get_project_settings = get_project_settings(project_name) _settings = ( - project_settings["ftrack"]["events"]["user_assignment"] + get_project_settings["ftrack"]["events"]["user_assignment"] ) project_data["scripts_by_action"] = _settings.get("scripts") tmp_by_project_name[project_name] = project_data diff --git a/pype/modules/ftrack/events/event_version_to_task_statuses.py b/pype/modules/ftrack/events/event_version_to_task_statuses.py index 6c4ebf2d10..ca55f24f32 100644 --- a/pype/modules/ftrack/events/event_version_to_task_statuses.py +++ b/pype/modules/ftrack/events/event_version_to_task_statuses.py @@ -1,5 +1,5 @@ from pype.modules.ftrack import BaseEvent -from pype.api import project_settings as get_project_settings +from pype.api import get_project_settings as get_project_settings class VersionToTaskStatus(BaseEvent): @@ -52,11 +52,11 @@ class VersionToTaskStatus(BaseEvent): project_entity = self.get_project_from_entity(task) project_name = project_entity["full_name"] - project_settings = get_project_settings(project_name) + get_project_settings = get_project_settings(project_name) # Load status mapping from presets status_mapping = ( - project_settings["ftrack"]["event"]["status_version_to_task"] + get_project_settings["ftrack"]["event"]["status_version_to_task"] ) # Skip if mapping is empty if not status_mapping: diff --git a/pype/plugin.py b/pype/plugin.py index 8d53e9c4be..1b769cd1f1 100644 --- a/pype/plugin.py +++ b/pype/plugin.py @@ -2,7 +2,7 @@ import tempfile import os import pyblish.api -from pype.api import project_settings +from pype.api import get_project_settings import inspect ValidatePipelineOrder = pyblish.api.ValidatorOrder + 0.05 @@ -24,7 +24,7 @@ def imprint_attributes(plugin): plugin_host = file.split(os.path.sep)[-3:-2][0] plugin_name = type(plugin).__name__ try: - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) settings_data = settings[plugin_host][plugin_kind][plugin_name] # noqa: E501 print(settings_data) except KeyError: diff --git a/pype/plugins/maya/create/create_rendersetup.py b/pype/plugins/maya/create/create_rendersetup.py index 406d90223f..969c085ea6 100644 --- a/pype/plugins/maya/create/create_rendersetup.py +++ b/pype/plugins/maya/create/create_rendersetup.py @@ -26,9 +26,9 @@ class CreateRenderSetup(avalon.maya.Creator): # \__| | # \_____/ - # from pype.api import project_settings + # from pype.api import get_project_settings # import maya.app.renderSetup.model.renderSetup as renderSetup - # settings = project_settings(os.environ['AVALON_PROJECT']) + # settings = get_project_settings(os.environ['AVALON_PROJECT']) # layer = settings['maya']['create']['renderSetup']["layer"] # rs = renderSetup.instance() diff --git a/pype/plugins/maya/load/load_ass.py b/pype/plugins/maya/load/load_ass.py index dc3e0043ee..9b851a3757 100644 --- a/pype/plugins/maya/load/load_ass.py +++ b/pype/plugins/maya/load/load_ass.py @@ -1,7 +1,7 @@ from avalon import api import pype.hosts.maya.plugin import os -from pype.api import project_settings +from pype.api import get_project_settings import clique @@ -74,7 +74,7 @@ class AssProxyLoader(pype.hosts.maya.plugin.ReferenceLoader): proxyShape.dso.set(path) proxyShape.aiOverrideShaders.set(0) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get(family) @@ -196,7 +196,7 @@ class AssStandinLoader(api.Loader): label = "{}:{}".format(namespace, name) root = pm.group(name=label, empty=True) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get('ass') diff --git a/pype/plugins/maya/load/load_gpucache.py b/pype/plugins/maya/load/load_gpucache.py index 6520be0a07..0b3daae710 100644 --- a/pype/plugins/maya/load/load_gpucache.py +++ b/pype/plugins/maya/load/load_gpucache.py @@ -1,7 +1,7 @@ from avalon import api import pype.hosts.maya.plugin import os -from pype.api import project_settings +from pype.api import get_project_settings reload(config) @@ -35,7 +35,7 @@ class GpuCacheLoader(api.Loader): label = "{}:{}".format(namespace, name) root = cmds.group(name=label, empty=True) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get('model') if c is not None: diff --git a/pype/plugins/maya/load/load_reference.py b/pype/plugins/maya/load/load_reference.py index 90a3015894..23b3cedb55 100644 --- a/pype/plugins/maya/load/load_reference.py +++ b/pype/plugins/maya/load/load_reference.py @@ -2,7 +2,7 @@ import pype.hosts.maya.plugin from avalon import api, maya from maya import cmds import os -from pype.api import project_settings +from pype.api import get_project_settings class ReferenceLoader(pype.hosts.maya.plugin.ReferenceLoader): @@ -77,7 +77,7 @@ class ReferenceLoader(pype.hosts.maya.plugin.ReferenceLoader): cmds.setAttr(groupName + ".displayHandle", 1) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get(family) if c is not None: diff --git a/pype/plugins/maya/load/load_vdb_to_redshift.py b/pype/plugins/maya/load/load_vdb_to_redshift.py index 885f0f23c8..17c78d7165 100644 --- a/pype/plugins/maya/load/load_vdb_to_redshift.py +++ b/pype/plugins/maya/load/load_vdb_to_redshift.py @@ -1,6 +1,6 @@ from avalon import api import os -from pype.api import project_settings +from pype.api import get_project_settings class LoadVDBtoRedShift(api.Loader): """Load OpenVDB in a Redshift Volume Shape""" @@ -55,7 +55,7 @@ class LoadVDBtoRedShift(api.Loader): label = "{}:{}".format(namespace, name) root = cmds.group(name=label, empty=True) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get(family) diff --git a/pype/plugins/maya/load/load_vdb_to_vray.py b/pype/plugins/maya/load/load_vdb_to_vray.py index 9bfdda0308..2959ef42ec 100644 --- a/pype/plugins/maya/load/load_vdb_to_vray.py +++ b/pype/plugins/maya/load/load_vdb_to_vray.py @@ -1,5 +1,5 @@ from avalon import api -from pype.api import project_settings +from pype.api import get_project_settings import os @@ -48,7 +48,7 @@ class LoadVDBtoVRay(api.Loader): label = "{}:{}".format(namespace, name) root = cmds.group(name=label, empty=True) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get(family) diff --git a/pype/plugins/maya/load/load_vrayproxy.py b/pype/plugins/maya/load/load_vrayproxy.py index 1294df2fc7..73f02b81e4 100644 --- a/pype/plugins/maya/load/load_vrayproxy.py +++ b/pype/plugins/maya/load/load_vrayproxy.py @@ -1,6 +1,6 @@ from avalon.maya import lib from avalon import api -from pype.api import project_settings +from pype.api import get_project_settings import os import maya.cmds as cmds @@ -47,7 +47,7 @@ class VRayProxyLoader(api.Loader): return # colour the group node - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get(family) if c is not None: diff --git a/pype/plugins/maya/load/load_yeti_cache.py b/pype/plugins/maya/load/load_yeti_cache.py index 8ee1602202..19cf3920fe 100644 --- a/pype/plugins/maya/load/load_yeti_cache.py +++ b/pype/plugins/maya/load/load_yeti_cache.py @@ -9,7 +9,7 @@ from maya import cmds from avalon import api, io from avalon.maya import lib as avalon_lib, pipeline from pype.hosts.maya import lib -from pype.api import project_settings +from pype.api import get_project_settings from pprint import pprint @@ -59,7 +59,7 @@ class YetiCacheLoader(api.Loader): group_name = "{}:{}".format(namespace, name) group_node = cmds.group(nodes, name=group_name) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get(family) diff --git a/pype/plugins/maya/load/load_yeti_rig.py b/pype/plugins/maya/load/load_yeti_rig.py index bd74fcbc43..3a9339c707 100644 --- a/pype/plugins/maya/load/load_yeti_rig.py +++ b/pype/plugins/maya/load/load_yeti_rig.py @@ -1,7 +1,7 @@ import os from collections import defaultdict -from pype.api import project_settings +from pype.api import get_project_settings import pype.hosts.maya.plugin from pype.hosts.maya import lib @@ -77,7 +77,7 @@ class YetiRigLoader(pype.hosts.maya.plugin.ReferenceLoader): groupName = "{}:{}".format(namespace, name) - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) colors = settings['maya']['load']['colors'] c = colors.get('yetiRig') diff --git a/pype/plugins/nuke/load/load_mov.py b/pype/plugins/nuke/load/load_mov.py index 078127ee42..104f59d5be 100644 --- a/pype/plugins/nuke/load/load_mov.py +++ b/pype/plugins/nuke/load/load_mov.py @@ -4,7 +4,7 @@ import contextlib from avalon import api, io from pype.hosts.nuke import presets -from pype.api import project_settings +from pype.api import get_project_settings @contextlib.contextmanager @@ -73,7 +73,7 @@ def add_review_presets_config(): "families": list(), "representations": list() } - settings = project_settings(io.Session["AVALON_PROJECT"]) + settings = get_project_settings(io.Session["AVALON_PROJECT"]) review_presets = settings["global"]["publish"].get( "ExtractReview", {}) diff --git a/pype/tools/pyblish_pype/control.py b/pype/tools/pyblish_pype/control.py index 0994e25d4a..4f7a43d6d1 100644 --- a/pype/tools/pyblish_pype/control.py +++ b/pype/tools/pyblish_pype/control.py @@ -22,7 +22,7 @@ import pyblish.version from . import util from .constants import InstanceStates -from pype.api import project_settings +from pype.api import get_project_settings class IterationBreak(Exception): @@ -121,7 +121,7 @@ class Controller(QtCore.QObject): def presets_by_hosts(self): # Get global filters as base - presets = project_settings(os.environ['AVALON_PROJECT']) or {} + presets = get_project_settings(os.environ['AVALON_PROJECT']) or {} if not presets: return {} diff --git a/pype/tools/standalonepublish/widgets/widget_family.py b/pype/tools/standalonepublish/widgets/widget_family.py index be68e411fd..5c0c8ccd38 100644 --- a/pype/tools/standalonepublish/widgets/widget_family.py +++ b/pype/tools/standalonepublish/widgets/widget_family.py @@ -5,7 +5,7 @@ from Qt import QtWidgets, QtCore from . import HelpRole, FamilyRole, ExistsRole, PluginRole, PluginKeyRole from . import FamilyDescriptionWidget -from pype.api import project_settings +from pype.api import get_project_settings class FamilyWidget(QtWidgets.QWidget): @@ -310,7 +310,7 @@ class FamilyWidget(QtWidgets.QWidget): def refresh(self): has_families = False - settings = project_settings(os.environ['AVALON_PROJECT']) + settings = get_project_settings(os.environ['AVALON_PROJECT']) sp_settings = settings.get('standalonepublisher', {}) print(sp_settings) diff --git a/setup/maya/userSetup.py b/setup/maya/userSetup.py index 3cf2718796..e401580bd8 100644 --- a/setup/maya/userSetup.py +++ b/setup/maya/userSetup.py @@ -1,5 +1,5 @@ import os -from pype.api import project_settings +from pype.api import get_project_settings import pype.hosts.maya.lib as mlib from maya import cmds @@ -7,7 +7,7 @@ from maya import cmds print("starting PYPE usersetup") # build a shelf -settings = project_settings(os.environ['AVALON_PROJECT']) +settings = get_project_settings(os.environ['AVALON_PROJECT']) shelf_preset = settings['maya'].get('project_shelf')