diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..9a651ef --- /dev/null +++ b/.flake8 @@ -0,0 +1,64 @@ +# Copyright (c) 2017 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +# Flake 8 PEP and lint configuration - https://gitlab.com/pycqa/flake8 +# +# This defines the official lint and PEP8 rules for this repository +# +# You can run this locally by doing pep install flake8 and then +# >flake8 /path/to/core +# +# This is also used by the hound CI - see the .hound.yml config file. +# +# +[flake8] + +# things we don't want to lint +exclude = + .tox, + .git, + .flake8, + .gitignore, + .travis.yml, + .cache, + .eggs, + *.rst, + *.yml, + *.pyc, + *.pyo, + *.egg-info, + __pycache__, + # Those are our third parties, do not lint them! + python/tank_vendor, + # Otherwise you'll have a lot of 'xxx' imported but unused + python/tank/__init__.py, + python/tank/*/__init__.py, + # Skip the auto-generated ui file. + python/tank/authentication/ui/login_dialog.py, + python/tank/authentication/ui/resources_rc.py, + python/tank/platform/qt/ui_busy_dialog.py, + python/tank/platform/qt/ui_item.py, + python/tank/platform/qt/ui_tank_dialog.py, + python/tank/authentication/sso_saml2/*, + tests/python + +# toolkit exceptions +# +# E203 whitespace before ':' (this is not PEP8 compliant) +# E221 multiple spaces before operator +# E261 two whitespaces before end of line comment. +# E402 module level import not top of file +# E501 line too long (112 > 79 characters) +# W503 Line break occurred before a binary operator +# N802 Variables should be lower case. (clashes with Qt naming conventions) +# N806 Variables should be lower case. (clashes with Qt naming conventions) +# E999 SyntaxError: invalid syntax (hack for hound CI which runs python 3.x) + +ignore = E203, E221, E261, E402, E501, W503, N802, N806, E999 diff --git a/.gitignore b/.gitignore index 62e284f..09d8263 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,9 @@ nosetests.xml # Ideavim .idea + +# IDEs and Editors +*.swo +*.swp +*.swm +*~ diff --git a/python/tk_multi_loader/flowam/__init__.py b/python/tk_multi_loader/flowam/__init__.py index 07cb706..b4bd38f 100644 --- a/python/tk_multi_loader/flowam/__init__.py +++ b/python/tk_multi_loader/flowam/__init__.py @@ -15,6 +15,8 @@ of the ShotGrid REST API. """ +# flake8: noqa + import sgtk logger = sgtk.platform.get_logger(__name__) diff --git a/python/tk_multi_loader/flowam/create.py b/python/tk_multi_loader/flowam/create.py index ca9ca93..67b71c3 100644 --- a/python/tk_multi_loader/flowam/create.py +++ b/python/tk_multi_loader/flowam/create.py @@ -54,8 +54,6 @@ class CreateInputs(flowam_utils.BaseInputs): sg_pipeline_step: str #: The AM project under which the asset should be added. am_project_id: str - #: The name of the current SG task. - sg_task_name: str = "" #: Description of asset. description: str = "" #: Determines which initial source file to use to create the asset. @@ -102,10 +100,6 @@ def validate(self): if self.create_mode == create.CreateMode.GENERIC and not self.source_path: msg = "No source path provided for generic asset." raise exceptions.CreateAssetError(data=self.asdict(), details=msg) - # If pipeline step is provided, we expect task_name to be provided as well - if self.sg_pipeline_step and not self.sg_task_name: - msg = "Incomplete sg context provided. Must provide sg_task_name." - raise exceptions.CreateAssetError(data=self.asdict(), details=msg) # prep_scene_callback is only applicable when create_mode is NEW or TEMPLATE if ( self.create_mode == create.CreateMode.GENERIC @@ -283,14 +277,6 @@ def in_dcc_context() -> bool: return engine.name != "tk-desktop" -def _has_workfile_type(parent: objects.FlowAsset, type_id: str) -> bool: - """Return True if parent asset contains a child of given type.""" - - if parent.find_children(type_id=type_id): - return True - return False - - def _create_dcc_workfile_asset( parent: objects.FlowAsset, inputs: CreateInputs ) -> sandbox.NewDraftInfo: @@ -313,15 +299,9 @@ def _create_dcc_workfile_asset( workfile_type = flow_host().WORKFILE_TYPE type_id = schema.get_schema_id(workfile_type) - # Only allow one workfile of DCC type under parent - if _has_workfile_type(parent, type_id): - msg = f'A workfile of type "{workfile_type}" has already been created ' - msg += f'under pipeline step "{parent.name}". Please open the asset from ' - msg += "the Loader app to publish another revision of this asset." - raise exceptions.CreateAssetError(data=inputs.asdict(), details=msg) - - # By convention asset name will be the sg entity name - name = inputs.sg_entity_name + # By convention asset name will be the sg entity name + workfile type + abbr_type = workfile_type.split(".")[-1].upper() + name = f"{inputs.sg_entity_name} - {abbr_type}" # Prepare the source file and save to temporary location # By convention the source file will be named after the asset diff --git a/python/tk_multi_loader/flowam/flowam_actions.py b/python/tk_multi_loader/flowam/flowam_actions.py index c12e6d9..c0b9782 100644 --- a/python/tk_multi_loader/flowam/flowam_actions.py +++ b/python/tk_multi_loader/flowam/flowam_actions.py @@ -167,7 +167,6 @@ def _on_build_scene_dialog_accepted( sg_pipeline_step=(task.get("step") or {}).get( "name", "" ), # Layout, Animation, etc. - sg_task_name=sg_publish_data["content"], am_project_id=flow_am_id, create_mode=dialog.build, source_path=template_path, diff --git a/python/tk_multi_loader/flowam/template_queries.py b/python/tk_multi_loader/flowam/template_queries.py index 3092d18..18796c6 100644 --- a/python/tk_multi_loader/flowam/template_queries.py +++ b/python/tk_multi_loader/flowam/template_queries.py @@ -12,7 +12,7 @@ from __future__ import annotations -from typing import Any, Optional +from typing import Optional import sgtk from sgtk.flowam.create import PIPELINE_STEP_TYPE, TEMPLATE_FOLDER, TEMPLATE_TYPE