Skip to content

Commit

Permalink
remove trailing spaces from path segments (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Sep 24, 2016
1 parent 8133170 commit 581daeb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gallery_dl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ def __init__(self, url):
self.filename_fmt = config.interpolate(
key + ["filename_fmt"], default=self.extractor.filename_fmt
)
segments = config.interpolate(
self.directory_fmt = config.interpolate(
key + ["directory_fmt"], default=self.extractor.directory_fmt
)
self.directory_fmt = os.path.join(*segments)

def run(self):
for msg in self.extractor:
Expand Down Expand Up @@ -96,11 +95,13 @@ def download(self, msg):

def set_directory(self, msg):
"""Set and create the target directory for downloads"""
segments = [
text.clean_path(segment.format(**msg[1]).strip())
for segment in self.directory_fmt
]
self.directory = os.path.join(
self.get_base_directory(),
self.directory_fmt.format(**{
key: text.clean_path(value) for key, value in msg[1].items()
})
*segments
)
os.makedirs(self.directory, exist_ok=True)

Expand Down

0 comments on commit 581daeb

Please sign in to comment.