From 66a03d9b1217b284c63e39a4b2998f438263ecc1 Mon Sep 17 00:00:00 2001 From: Luca Baffa <47544021+lb803@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:48:19 +0000 Subject: [PATCH] use os.path.splitext() to get the file basename --- src/epublius/metadata.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/epublius/metadata.py b/src/epublius/metadata.py index af39035..b4263d2 100644 --- a/src/epublius/metadata.py +++ b/src/epublius/metadata.py @@ -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)