Ejemplo n.º 1
0
    def parser(self):
        # Don't call super to user the Parser of anyblok
        kwargs = {"usage": self.usage, "prog": self.prog}
        parser = getParser(**kwargs)
        parser.add_argument("-v",
                            "--version",
                            action="version",
                            default=argparse.SUPPRESS,
                            version="%(prog)s (version " + __version__ + ")\n",
                            help="show program's version number and exit")
        parser.add_argument("args", nargs="*", help=argparse.SUPPRESS)

        keys = sorted(self.settings, key=self.settings.__getitem__)
        for k in keys:
            self.settings[k].add_option(parser)

        description = {}
        if self.application in Configuration.applications:
            description.update(Configuration.applications[self.application])
        else:
            description.update(Configuration.applications['default'])

        configuration_groups = description.pop('configuration_groups',
                                               ['gunicorn', 'database'])
        if 'plugins' not in configuration_groups:
            configuration_groups.append('plugins')

        Configuration._load(parser, configuration_groups)
        return parser
Ejemplo n.º 2
0
    def parser(self):
        # Don't call super to user the Parser of anyblok
        kwargs = {
            "usage": self.usage,
            "prog": self.prog
        }
        parser = getParser(**kwargs)
        parser.add_argument("-v", "--version",
                            action="version", default=argparse.SUPPRESS,
                            version="%(prog)s (version " + __version__ + ")\n",
                            help="show program's version number and exit")
        parser.add_argument("args", nargs="*", help=argparse.SUPPRESS)

        keys = sorted(self.settings, key=self.settings.__getitem__)
        for k in keys:
            self.settings[k].add_option(parser)

        description = {}
        if self.application in Configuration.applications:
            description.update(Configuration.applications[self.application])
        else:
            description.update(Configuration.applications['default'])

        configuration_groups = description.pop('configuration_groups',
                                               ['gunicorn', 'database'])
        if 'plugins' not in configuration_groups:
            configuration_groups.append('plugins')

        Configuration._load(parser, configuration_groups)
        return parser
Ejemplo n.º 3
0
    def test_add_application_properties_and_load_it(self):
        Configuration.add_application_properties(
            'test_add_application_properties', ['logging'])
        parser = MockArgumentParser()

        # add twice to check doublon
        Configuration.add('logging', function_=add_logging, label='Logging')
        Configuration.add('logging', function_=add_logging, label='Logging')

        Configuration.add('database', function_=add_database, label='Database')
        Configuration.add('config', function_=add_configuration_file)
        Configuration.add('install-bloks', function_=add_install_bloks)
        Configuration._load(parser, ['config', 'database', 'logging'])
Ejemplo n.º 4
0
    def test_add_application_properties_and_load_it(self):
        Configuration.add_application_properties(
            'test_add_application_properties', ['logging'])
        parser = MockArgumentParser()

        # add twice to check doublon
        Configuration.add('logging', function_=add_logging, label='Logging')
        Configuration.add('logging', function_=add_logging, label='Logging')

        Configuration.add('database', function_=add_database, label='Database')
        Configuration.add('config', function_=add_configuration_file)
        Configuration.add('install-bloks', function_=add_install_bloks)
        Configuration._load(parser, ['config', 'database', 'logging'])