1
0
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:
Mike Fährmann 2017-12-21 21:56:24 +01:00
parent d0886f411e
commit d241a0fb60
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -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