continues writing the string formating of multi page options

This commit is contained in:
Hellow2 2023-03-28 14:40:59 +02:00
parent 3a842920e8
commit bbb2f0831b
2 changed files with 17 additions and 3 deletions

View File

@ -5,6 +5,9 @@ def search_pages():
search = pages.Search("#a Happy Days")
print("metadata", search.pages)
print("audio", search.audio_pages)
print()
print(search._current_option)
if __name__ == "__main__":

View File

@ -4,7 +4,7 @@ from typing import Tuple, List, Set, Dict, Type
from . import page_attributes
from ..abstract import Page
from ...objects import Options
from ...objects import Options, DatabaseObject
class MultiPageOptions:
@ -27,10 +27,22 @@ class MultiPageOptions:
def __repr__(self) -> str:
lines: List[str] = []
page_name_fill = "-"
max_page_len = 21
j = 0
for page, options in self._current_option_dict.items():
lines.append(f"----------{page.__name__}----------")
lines.append(f"----------{page.__name__:{page_name_fill}<{max_page_len}}----------")
option_obj: DatabaseObject
for i, option_obj in enumerate(options):
if i >= self.max_displayed_options:
lines.append("...")
break
lines.append(f"{j+i:0{self.option_digits}} {option_obj.option_string}")
j += i + 1
return "\n".join(lines)
@ -99,5 +111,4 @@ class Search:
for page in self.pages:
self._current_option[page] = page.search_by_query(query=query)
print(self._current_option)