From 30ae76367f696e77297bf7d4eaadc8ddff39d914 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 2 Feb 2020 19:35:46 -0800 Subject: [PATCH] Simplify move_nav_to_end by calling spine.index. --- epubfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/epubfile.py b/epubfile.py index cf3c119..6568f4c 100644 --- a/epubfile.py +++ b/epubfile.py @@ -1097,11 +1097,11 @@ class Epub: return spine = self.get_spine_order() - for (index, id) in enumerate(spine): - if id == nav: - spine.append(spine.pop(index)) - break - else: + + try: + index = spine.index(nav) + spine.append(spine.pop(index)) + except ValueError: spine.append(nav) self.set_spine_order(spine)