Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ nosetests.xml

# Ideavim
.idea

# IDEs and Editors
*.swo
*.swp
*.swm
*~
2 changes: 2 additions & 0 deletions python/tk_multi_loader/flowam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
of the ShotGrid REST API.
"""

# flake8: noqa

import sgtk

logger = sgtk.platform.get_logger(__name__)
Expand Down
26 changes: 3 additions & 23 deletions python/tk_multi_loader/flowam/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion python/tk_multi_loader/flowam/flowam_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion python/tk_multi_loader/flowam/template_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from __future__ import annotations

from typing import Any, Optional
from typing import Optional

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


import sgtk
from sgtk.flowam.create import PIPELINE_STEP_TYPE, TEMPLATE_FOLDER, TEMPLATE_TYPE
Expand Down