mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
fix the slashes issue at the root
This commit is contained in:
parent
02ed6cb9e0
commit
6b452e4929
3 changed files with 16 additions and 6 deletions
|
|
@ -1113,11 +1113,6 @@ class IWorkfileHost:
|
|||
filepath = os.path.join(workdir, filename)
|
||||
|
||||
rootless_path = f"{rootless_workdir}/{filename}"
|
||||
# Double slashes can happen when root leads to root of disk or
|
||||
# when task exists on root folder
|
||||
# - '/{hierarchy}/{folder[name]}' -> '//some_folder'
|
||||
while "//" in rootless_path:
|
||||
rootless_path = rootless_path.replace("//", "/")
|
||||
workfile_entity = workfile_entities_by_path.pop(
|
||||
rootless_path, None
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import re
|
|||
import copy
|
||||
import numbers
|
||||
import warnings
|
||||
import platform
|
||||
from string import Formatter
|
||||
import typing
|
||||
from typing import List, Dict, Any, Set
|
||||
|
|
@ -12,6 +13,7 @@ if typing.TYPE_CHECKING:
|
|||
|
||||
SUB_DICT_PATTERN = re.compile(r"([^\[\]]+)")
|
||||
OPTIONAL_PATTERN = re.compile(r"(<.*?[^{0]*>)[^0-9]*?")
|
||||
_IS_WINDOWS = platform.system().lower() == "windows"
|
||||
|
||||
|
||||
class TemplateUnsolved(Exception):
|
||||
|
|
@ -277,8 +279,11 @@ class TemplateResult(str):
|
|||
"""Convert to normalized path."""
|
||||
|
||||
cls = self.__class__
|
||||
path = str(self)
|
||||
if _IS_WINDOWS:
|
||||
path = path.replace("\\", "/")
|
||||
return cls(
|
||||
os.path.normpath(self.replace("\\", "/")),
|
||||
os.path.normpath(path),
|
||||
self.template,
|
||||
self.solved,
|
||||
self.used_values,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import re
|
||||
import copy
|
||||
import platform
|
||||
import collections
|
||||
import numbers
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ from .exceptions import (
|
|||
AnatomyTemplateUnsolved,
|
||||
)
|
||||
|
||||
_IS_WINDOWS = platform.system().lower() == "windows"
|
||||
_PLACEHOLDER = object()
|
||||
|
||||
|
||||
|
|
@ -526,6 +528,14 @@ class AnatomyTemplates:
|
|||
root_key = "{" + root_key + "}"
|
||||
output = output.replace(str(used_value), root_key)
|
||||
|
||||
# Make sure rootless path is with forward slashes
|
||||
if _IS_WINDOWS:
|
||||
output.replace("\\", "/")
|
||||
|
||||
# Make sure there are no double slashes
|
||||
while "//" in output:
|
||||
output = output.replace("//", "/")
|
||||
|
||||
return output
|
||||
|
||||
def format(self, data, strict=True):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue