Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2015 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of toktokkie.
6toktokkie is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11toktokkie is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20import os
21from abc import ABC
22from typing import Dict, Any, List
23from puffotter.os import listdir, makedirs
24from puffotter.prompt import prompt_comma_list
25from toktokkie.metadata.base.Prompter import Prompter
26from toktokkie.metadata.comic.ComicExtras import ComicExtras
29class ComicPrompter(Prompter, ComicExtras, ABC):
30 """
31 Implements the Prompter functionality for comic metadata
32 """
34 @classmethod
35 def prompt(cls, directory_path: str) -> Dict[str, Any]:
36 """
37 Generates new Metadata JSON using prompts for a directory
38 :param directory_path: The path to the directory for which to generate
39 the metadata object
40 :return: The generated metadata JSON
41 """
42 base = super().prompt(directory_path)
44 main_path = os.path.join(directory_path, "Main")
45 makedirs(main_path)
46 special_path = os.path.join(directory_path, "Special")
47 special_chapters: List[str] = []
49 if os.path.isdir(special_path):
50 print("Please enter identifiers for special chapters:")
52 special_files = listdir(special_path, no_dirs=True)
53 for name, _ in special_files:
54 print(name)
56 special_chapters = prompt_comma_list(
57 "Special Chapters", min_count=len(special_files)
58 )
60 base.update({
61 "special_chapters": special_chapters
62 })
63 return base