Exemplo n.º 1
0
    def format_help(self):
        formatter = self._get_formatter()
        formatter.add_usage(self.usage, self._actions, self._mutually_exclusive_groups)
        formatter.add_text(self.description)

        for action_group in self._action_groups:
            formatter.start_section(action_group.title)
            formatter.add_text(action_group.description)
            formatter.add_arguments(action_group._group_actions)
            formatter.end_section()
        formatter.add_text(self.epilog)

        formatter.start_section('commands')
        for name, command in sorted(COMMANDS.items()):
            descr = command.get_parser().description.split('\n')[0]
            formatter.add_argument(Action([name], '', help=descr))
        formatter.end_section()

        return formatter.format_help()
Exemplo n.º 2
0
 def __call__(self, *a, **kw):
     actions = [
         Action([i], help=getattr(pathmaker, i).__doc__, dest='')
         for i in sorted(pathmaker.__all__)
         if not i.startswith('_') and callable(getattr(pathmaker, i))
     ]
     formatter = HelpFormatter('')
     formatter.add_text(
         "An explicit layout strategy can be specified.  This is to "
         "instruct how ExplosiveFUSE should present file entries across "
         "all archive files within its mount point.  Do note that "
         "the final outcome of the layout is also influenced by the usage "
         "of the '--overwrite' and the '--omit-arcname' flags, and "
         "arguments which may associate with each of the strategies. "
         "They are specified by appending ':', followed by the value of "
         "each positional argument(s).")
     formatter.start_section('Available layout strategies')
     formatter.add_arguments(actions)
     formatter.end_section()
     print(formatter.format_help())
     sys.exit(0)
Exemplo n.º 3
0
 def test_format_action_invocation(self):
     action = Action("d", "a")
     fmt = lp.NewFormatter("lol.py")
     assert fmt._format_action_invocation(action) == "d A"
     action = Action("d", "a", nargs=0)
     assert fmt._format_action_invocation(action) == "d"
Exemplo n.º 4
0
 def test_format_args(self):
     action = Action("-a", "a")
     fmt = lp.NewFormatter("lol.py")
     assert fmt._format_args(action, "a") == "a"
Exemplo n.º 5
0
 def test_base_action(self):
     action = Action()
     action.read_config_from_file()
     res = action.get_url('kattis', 'hostname')
     self.assertEqual(res, 'https://open.kattis.com/hostname')