Skip to content

Commit

Permalink
Renamed toc_item id property to toc_id throughout to avoid pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrigg committed Dec 29, 2023
1 parent 815936a commit 99ae123
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions se/se_epub_generate_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TocItem:
subtitle = ""
title_is_ordinal = False
lang = ""
id = ""
toc_id = ""
epub_type = ""
division = BookDivision.NONE
place = Position.FRONT
Expand Down Expand Up @@ -427,7 +427,7 @@ def process_headings(dom: EasyXmlTree, textf: str, toc_list: list, single_file:
if special_item.title is None:
special_item.title = "NO TITLE"
special_item.file_link = textf
special_item.id = textf.replace('.xhtml','') # quick and dirty way of getting the id of a special item
special_item.toc_id = textf.replace('.xhtml','') # quick and dirty way of getting the id of a special item
special_item.place = place
toc_list.append(special_item)
return
Expand Down Expand Up @@ -485,7 +485,7 @@ def get_level(node: EasyXmlElement, toc_list: list) -> int:

if data_parent:
# see if we can find it in already processed (as we should if spine is correctly ordered)
parent_file = [t for t in toc_list if t.id == data_parent]
parent_file = [t for t in toc_list if t.toc_id == data_parent]
if parent_file:
this_level = parent_file[0].level + 1
return this_level + depth - 1 # subtract from depth because all headings should have depth >= 1
Expand All @@ -512,14 +512,14 @@ def process_a_heading(node: EasyXmlElement, textf: str, is_toplevel: bool, singl

# is_top_level stops the first heading in a file getting an anchor id, we don't generally want that.
# The exceptions are things like poems within a single-file volume.
toc_item.id = get_parent_id(node) # pylint: disable=invalid-name
if toc_item.id == "":
toc_item.toc_id = get_parent_id(node) # pylint: disable=invalid-name
if toc_item.toc_id == "":
toc_item.file_link = textf
else:
if not is_toplevel:
toc_item.file_link = f"{textf}#{toc_item.id}"
toc_item.file_link = f"{textf}#{toc_item.toc_id}"
elif single_file: # It IS the first heading in the file, but there's only a single content file?
toc_item.file_link = f"{textf}#{toc_item.id}"
toc_item.file_link = f"{textf}#{toc_item.toc_id}"
else:
toc_item.file_link = textf

Expand Down

0 comments on commit 99ae123

Please sign in to comment.