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 argparse
21from toktokkie.commands.Command import Command
22from toktokkie.Directory import Directory
23from toktokkie.utils.iconizing.Iconizer import Iconizer
26class IconizeCommand(Command):
27 """
28 Class that encapsulates behaviour of the iconize command
29 """
31 @classmethod
32 def name(cls) -> str:
33 """
34 :return: The command name
35 """
36 return "iconize"
38 @classmethod
39 def help(cls) -> str:
40 """
41 :return: The help message for the command
42 """
43 return "Applies folder icons"
45 @classmethod
46 def prepare_parser(cls, parser: argparse.ArgumentParser):
47 """
48 Prepares an argumentparser for this command
49 :param parser: The parser to prepare
50 :return: None
51 """
52 procedure_names = {x.name for x in Iconizer.all_procedures}
54 cls.add_directories_arg(parser)
55 parser.add_argument("procedure", choices=procedure_names, nargs="?",
56 default=Iconizer.default_procedure().name,
57 help="The procedure to use")
59 def execute(self):
60 """
61 Executes the commands
62 :return: None
63 """
64 procedure = list(filter(
65 lambda x: x.name == self.args.procedure, Iconizer.all_procedures
66 ))[0]
68 for directory in Directory.load_directories(self.args.directories):
69 iconizer = Iconizer(directory.metadata, procedure)
70 iconizer.iconize()