From fea58d919a72b97c5827ddcf676fb39ab4d26c5b Mon Sep 17 00:00:00 2001 From: Nandaka Date: Thu, 23 Jan 2020 17:12:55 +0800 Subject: [PATCH] Fix #627: handle trailing '.' --- PixivHelper.py | 7 +++++++ PixivImage.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/PixivHelper.py b/PixivHelper.py index 7c787705..8b940c03 100644 --- a/PixivHelper.py +++ b/PixivHelper.py @@ -102,6 +102,13 @@ def sanitize_filename(s, rootDir=None): temp2.append(item.strip()) name = os.sep.join(temp2) + # Issue #627: remove trailing '.' + name_split = name.split(os.sep) + for item in range(0, len(name_split)): + if name_split[item].endswith("."): + name_split[item] = name_split[item][:-1] + "_" + name = os.sep.join(name_split) + if rootDir is not None: name = rootDir + os.sep + name diff --git a/PixivImage.py b/PixivImage.py index 7c777d8d..c59d4b9a 100644 --- a/PixivImage.py +++ b/PixivImage.py @@ -335,7 +335,7 @@ def WriteInfo(self, filename): info = codecs.open(filename, 'wb', encoding='utf-8') except IOError: info = codecs.open(str(self.imageId) + ".txt", 'wb', encoding='utf-8') - PixivHelper.get_logger().exception("Error when saving image info: %s, file is saved to: %d.txt", filename, self.imageId) + PixivHelper.get_logger().exception("Error when saving image info: %s, file is saved to: %s.txt", filename, str(self.imageId)) info.write("ArtistID = " + str(self.artist.artistId) + "\r\n") info.write("ArtistName = " + self.artist.artistName + "\r\n")