Skip to content

Commit

Permalink
Fix #627: handle trailing '.'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandaka committed Jan 23, 2020
1 parent 8ce38f8 commit e8e19da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions PixivHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion PixivImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e8e19da

Please sign in to comment.