コード例 #1
0
ファイル: main.py プロジェクト: twaugh/journal-brief
    def get_formatters(self):
        """
        Build the list of formatters we'll use

        :return: list, EntryFormatter instances
        """
        if self.args.cmd == 'debrief':
            formatters = [get_formatter('config')]
        else:
            outputs = self.config.get('output',
                                      self.default_output_format).split(',')
            try:
                formatters = [get_formatter(output) for output in outputs]
            except KeyError as ex:
                sys.stderr.write("{0}: invalid output format '{1}'\n"
                                 .format(PACKAGE, ex.args[0]))
                sys.exit(1)

        return formatters
コード例 #2
0
ファイル: main.py プロジェクト: twaugh/journal-brief
    def show_output_help(self):
        """
        Respond to --help-output
        """

        print("Available output formats:")
        for output in list_formatters():
            print("\n{0}:".format(output))
            formatter = get_formatter(output)
            docstring = [line.strip()
                         for line in formatter.__doc__.splitlines()]
            while docstring and not docstring[0]:
                del docstring[0]
            while docstring and not docstring[-1]:
                del docstring[-1]
            print('\n'.join(['    ' + line for line in docstring]))

        print("\nMultiple output formats can be used at the same time.")
        print("The default is '{0}'".format(self.default_output_format))