Skip to content

Commit

Permalink
use os.path.splitext() to get the file basename
Browse files Browse the repository at this point in the history
  • Loading branch information
lb803 committed Mar 6, 2023
1 parent b9457ea commit 66a03d9
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/epublius/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ def get_chapter_title(self):
(title_node.string is not None):
ch_title = title_node.string
else:
# Strip extension from file name
basename = self.contents[self.index].split('.')[0]

# Replace hypens with spaces (if any)
basename = os.path.splitext(self.contents[self.index])[0]
title_words = basename.replace('-', ' ')

# Create a titlecased version of title words
ch_title = title_words.title()

return html.escape(ch_title)
Expand Down

0 comments on commit 66a03d9

Please sign in to comment.