🐛 fix dot in extension

This commit is contained in:
Ondrej Samohel 2025-02-27 17:35:37 +01:00
parent 575f9c6244
commit 0f0a987d91
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
2 changed files with 51 additions and 5 deletions

View file

@ -918,8 +918,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
template_item.template_data["frame"] = frame
template_item.template_data["ext"] = (
file_loc.file_path.suffix
)
file_loc.file_path.suffix.lstrip("."))
template_filled = path_template_object.format_strict(
template_item.template_data
)
@ -1026,7 +1025,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
template_item.template_object["path"]
)
template_item.template_data["ext"] = (
representation.get_trait(FileLocation).file_path.suffix.rstrip(".")
representation.get_trait(FileLocation).file_path.suffix.lstrip(".")
)
template_item.template_data.pop("frame", None)
with contextlib.suppress(MissingTraitError):
@ -1110,10 +1109,17 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
path (Path): Destination url of published file.
anatomy (Anatomy): Project anatomy part from instance.
Raises:
PublishError: If file does not exist.
Returns:
dict[str, Any]: Representation file info dictionary.
"""
if not path.exists():
msg = f"File '{path}' does not exist."
raise PublishError(msg)
return {
"id": create_entity_id(),
"name": path.name,
@ -1131,6 +1137,9 @@ class IntegrateTraits(pyblish.api.InstancePlugin):
) -> list[dict[str, str]]:
"""Get legacy files for a given representation.
This expects the file to exist - it must run after the transfer
is done.
Returns:
list: List of legacy files.

View file

@ -12,6 +12,11 @@ import pytest
from ayon_api.operations import (
OperationsSession,
)
from ayon_core.lib.file_transaction import (
FileTransaction,
)
from ayon_core.pipeline.anatomy import Anatomy
from ayon_core.pipeline.traits import (
Bundle,
@ -30,9 +35,20 @@ from ayon_core.pipeline.version_start import get_versioning_start
# Tagged,
# TemplatePath,
from ayon_core.plugins.publish.integrate_traits import IntegrateTraits
from ayon_core.plugins.publish.integrate_traits import (
IntegrateTraits,
TransferItem,
)
from ayon_core.settings import get_project_settings
from ayon_api.operations import (
OperationsSession,
new_product_entity,
new_representation_entity,
new_version_entity,
)
if TYPE_CHECKING:
import pytest_ayon
@ -315,6 +331,9 @@ def test_get_transfers_from_representation(
mock_context: pyblish.api.Context) -> None:
"""Test get_transfers_from_representation.
This tests getting actual transfers from the representations and
also the legacy files.
Todo: This test will benefit massively from a proper mocking of the
context. We need to parametrize the test with different
representations and test the output of the function.
@ -332,4 +351,22 @@ def test_get_transfers_from_representation(
assert len(transfers) == 22
for transfer in transfers:
...
assert transfer.checksum == TransferItem.get_checksum(
transfer.source)
file_transactions = FileTransaction(
# Enforce unique transfers
allow_queue_replacements=False)
for transfer in transfers:
file_transactions.add(
transfer.source.as_posix(),
transfer.destination.as_posix(),
mode=FileTransaction.MODE_COPY,
)
file_transactions.process()
for representation in representations:
files = integrator._get_legacy_files_for_representation( # noqa: SLF001
transfers, representation, anatomy=instance.data["anatomy"])