Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #324 from pypeclub/bugfix/1411-wrong-handling-of-s…
Browse files Browse the repository at this point in the history
…lashes-when-loading-on-mac
  • Loading branch information
mkolar authored May 4, 2021
2 parents 15d8439 + b5a55af commit cfd4191
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions avalon/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,10 @@ def path_from_represenation():
context = representation["context"]
context["root"] = root
path = format_template_with_optional_keys(context, template)
# Force replacing backslashes with forward slashed if not on
# windows
if platform.system().lower() != "windows":
path = path.replace("\\", "/")
except KeyError:
# Template references unavailable data
return None
Expand Down Expand Up @@ -1645,13 +1649,10 @@ def path_from_config():
)
return None

# hierarchy may be equal to "" so it is not possible to use `or`
hierarchy = asset.get("data", {}).get("hierarchy")
if hierarchy is None:
# default list() in get would not discover missing parents on asset
parents = asset.get("data", {}).get("parents")
if parents is not None:
hierarchy = "/".join(parents)
# default list() in get would not discover missing parents on asset
parents = asset.get("data", {}).get("parents")
if parents is not None:
hierarchy = "/".join(parents)

# Cannot fail, required members only
data = {
Expand All @@ -1674,6 +1675,11 @@ def path_from_config():

try:
path = format_template_with_optional_keys(data, template)
# Force replacing backslashes with forward slashed if not on
# windows
if platform.system().lower() != "windows":
path = path.replace("\\", "/")

except KeyError as e:
log.debug("Template references unavailable data: %s" % e)
return None
Expand All @@ -1688,6 +1694,11 @@ def path_from_data():
return None

path = representation["data"]["path"]
# Force replacing backslashes with forward slashed if not on
# windows
if platform.system().lower() != "windows":
path = path.replace("\\", "/")

if os.path.exists(path):
return os.path.normpath(path)

Expand Down

0 comments on commit cfd4191

Please sign in to comment.