Skip to content

Commit

Permalink
use pathlib to noramlize paths (means having only / instead of \)
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Nov 14, 2024
1 parent 04f4593 commit 21f64d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion modelbaker/ilitoppingmaker/ilitarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import datetime
import os
import pathlib

from ..libs.toppingmaker import Target
from ..libs.toppingmaker.utils import slugify
Expand Down Expand Up @@ -62,7 +63,9 @@ def ilidata_path_resolver(target, name, type):
_, relative_filedir_path = target.filedir_path(type)

id = target.unique_id_in_target_scope(target, slugify(f"{type}_{name}_001"))
path = os.path.join(relative_filedir_path, name).replace("\\", "/")
path = pathlib.PureWindowsPath(
os.path.join(relative_filedir_path, name)
).as_posix()
type = type
toppingfile = {"id": id, "path": path, "type": type}
target.toppingfileinfo_list.append(toppingfile)
Expand Down
3 changes: 2 additions & 1 deletion modelbaker/iliwrapper/ilicache.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import glob
import logging
import os
import pathlib
import re
import shutil
import urllib.parse
Expand Down Expand Up @@ -699,7 +700,7 @@ def download_file(self, netloc, url, file, dataset_id=None):
file_dir = os.path.dirname(file_path)
os.makedirs(file_dir, exist_ok=True)
# in case there are backslashes in the url, remove them
file_url = file_url.replace("\\", "/")
file_url = pathlib.PureWindowsPath(file_url).as_posix()
download_file(
file_url,
file_path,
Expand Down

0 comments on commit 21f64d6

Please sign in to comment.