mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 20:22:36 +01:00
[util] replace '/' with '\' in base-directory paths
... on Windows to have consistent path separators.
This commit is contained in:
parent
d0886f411e
commit
d241a0fb60
@ -132,6 +132,8 @@ def expand_path(path):
|
||||
"""Expand environment variables and tildes (~)"""
|
||||
if not path:
|
||||
return path
|
||||
if not isinstance(path, str):
|
||||
path = os.path.join(*path)
|
||||
return os.path.expandvars(os.path.expanduser(path))
|
||||
|
||||
|
||||
@ -353,10 +355,10 @@ class PathFormat():
|
||||
self.directory = self.realdirectory = ""
|
||||
self.path = self.realpath = self.partpath = ""
|
||||
|
||||
bdir = extractor.config("base-directory", (".", "gallery-dl"))
|
||||
if not isinstance(bdir, str):
|
||||
bdir = os.path.join(*bdir)
|
||||
self.basedirectory = expand_path(bdir)
|
||||
self.basedirectory = expand_path(
|
||||
extractor.config("base-directory", (".", "gallery-dl")))
|
||||
if os.altsep:
|
||||
self.basedirectory = self.basedirectory.replace(os.altsep, os.sep)
|
||||
|
||||
skipmode = extractor.config("skip", True)
|
||||
if skipmode == "abort":
|
||||
@ -407,7 +409,7 @@ class PathFormat():
|
||||
self.keywords["extension"] = extension
|
||||
self.build_path()
|
||||
|
||||
def build_path(self, sep=os.path.sep):
|
||||
def build_path(self):
|
||||
"""Use filename-keywords and directory to build a full path"""
|
||||
try:
|
||||
filename = text.clean_path(
|
||||
@ -415,7 +417,7 @@ class PathFormat():
|
||||
except Exception as exc:
|
||||
raise exception.FormatError(exc, "filename")
|
||||
|
||||
filename = sep + filename
|
||||
filename = os.sep + filename
|
||||
self.path = self.directory + filename
|
||||
self.realpath = self.realdirectory + filename
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user