Ejemplo n.º 1
0
    def test_option_specified_twice(self):
        """Test schemaconfigglue with option name specified twice."""
        class MySchema(Schema):
            foo = IntOption(short_name='f')

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(
            parser, argv=['-f', '42', '--foo', '24'])
        self.assertEqual(parser.get('__main__', 'foo'), 24)
        op, options, args = schemaconfigglue(
            parser, argv=['-f', '24', '--foo', '42'])
        self.assertEqual(parser.get('__main__', 'foo'), 42)
Ejemplo n.º 2
0
    def test_option_specified_twice(self):
        """Test schemaconfigglue with option name specified twice."""
        class MySchema(Schema):
            foo = IntOption(short_name='f')

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(parser,
                                             argv=['-f', '42', '--foo', '24'])
        self.assertEqual(parser.get('__main__', 'foo'), 24)
        op, options, args = schemaconfigglue(parser,
                                             argv=['-f', '24', '--foo', '42'])
        self.assertEqual(parser.get('__main__', 'foo'), 42)
Ejemplo n.º 3
0
    def test_glue_no_argv(self):
        """Test schemaconfigglue with the default argv value."""
        config = StringIO("[__main__]\nbaz=1")
        self.parser.readfp(config)
        self.assertEqual(self.parser.values(), {
            'foo': {
                'bar': 0
            },
            '__main__': {
                'baz': 1
            }
        })

        _argv, sys.argv = sys.argv, []
        try:
            op, options, args = schemaconfigglue(self.parser)
            self.assertEqual(self.parser.values(), {
                'foo': {
                    'bar': 0
                },
                '__main__': {
                    'baz': 1
                }
            })
        finally:
            sys.argv = _argv
Ejemplo n.º 4
0
    def test_option_short_name(self):
        """Test schemaconfigglue support for short option names."""
        class MySchema(Schema):
            foo = IntOption(short_name='f')

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(parser, argv=['-f', '42'])
        self.assertEqual(parser.get('__main__', 'foo'), 42)
Ejemplo n.º 5
0
 def test_parser_unicode(self):
     s = textwrap.dedent("""
         [__main__]
         bar = zátrapa
     """)
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 6
0
    def test_parser_set_with_encoding(self):
        """Test schemaconfigglue override an option with a non-ascii value."""
        class MySchema(Schema):
            foo = StringOption()

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(parser, argv=['--foo', 'fóobâr'])
        self.assertEqual(parser.get('__main__', 'foo', parse=False), 'fóobâr')
        self.assertEqual(parser.get('__main__', 'foo'), 'fóobâr')
Ejemplo n.º 7
0
    def test_option_short_name(self):
        """Test schemaconfigglue support for short option names."""
        class MySchema(Schema):
            foo = IntOption(short_name='f')

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(
            parser, argv=['-f', '42'])
        self.assertEqual(parser.get('__main__', 'foo'), 42)
Ejemplo n.º 8
0
    def test_fatal_option_with_config(self):
        class MySchema(Schema):
            foo = IntOption(fatal=True)

        config = StringIO("[__main__]\nfoo=1")
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)

        op, options, args = schemaconfigglue(parser)
        self.assertEqual(parser.values(), {'__main__': {'foo': 1}})
Ejemplo n.º 9
0
    def test_fatal_option_with_config(self):
        class MySchema(Schema):
            foo = IntOption(fatal=True)

        config = StringIO("[__main__]\nfoo=1")
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)

        op, options, args = schemaconfigglue(parser)
        self.assertEqual(parser.values(), {'__main__': {'foo': 1}})
Ejemplo n.º 10
0
 def test_parser_unicode(self):
     s = textwrap.dedent("""
         [__main__]
         bar = zátrapa
         bar.parser = unicode
         bar.parser.args = utf-8
     """)
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 11
0
    def test_glue_no_op(self):
        """Test schemaconfigglue with the default OptionParser value."""
        config = StringIO("[__main__]\nbaz=1")
        self.parser.readfp(config)
        self.assertEqual(self.parser.values(),
            {'foo': {'bar': 0}, '__main__': {'baz': 1}})

        op, options, args = schemaconfigglue(self.parser, argv=['--baz', '2'])
        self.assertEqual(self.parser.values(),
            {'foo': {'bar': 0}, '__main__': {'baz': 2}})
Ejemplo n.º 12
0
    def test_glue_json_dict(self):
        class MySchema(Schema):
            foo = DictOption()

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(parser,
            argv=['--foo', '{"bar": "baz"}'])

        self.assertEqual(options, {'foo': '{"bar": "baz"}'})
        self.assertEqual(parser.values(),
            {'__main__': {'foo': {'bar': 'baz'}}})
Ejemplo n.º 13
0
    def test_glue_section_option(self):
        """Test schemaconfigglue overriding one option."""
        config = StringIO("[foo]\nbar=1")
        self.parser.readfp(config)
        self.assertEqual(self.parser.values(),
            {'foo': {'bar': 1}, '__main__': {'baz': 0}})

        op, options, args = schemaconfigglue(self.parser,
                                             argv=['--foo_bar', '2'])
        self.assertEqual(self.parser.values(),
                         {'foo': {'bar': 2}, '__main__': {'baz': 0}})
Ejemplo n.º 14
0
    def test_parser_set_with_encoding(self):
        """Test schemaconfigglue override an option with a non-ascii value."""
        class MySchema(Schema):
            foo = StringOption()

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(
            parser, argv=['--foo', 'fóobâr'])
        self.assertEqual(parser.get('__main__', 'foo', parse=False),
            'fóobâr')
        self.assertEqual(parser.get('__main__', 'foo'), 'fóobâr')
Ejemplo n.º 15
0
    def test_glue_environ(self, mock_os):
        mock_os.environ = {'CONFIGGLUE_FOO_BAR': '42', 'CONFIGGLUE_BAZ': 3}
        config = BytesIO(b"[foo]\nbar=1")
        self.parser.readfp(config)

        _argv, sys.argv = sys.argv, ['prognam']
        try:
            op, options, args = schemaconfigglue(self.parser)
            self.assertEqual(self.parser.values(),
                {'foo': {'bar': 42}, '__main__': {'baz': 3}})
        finally:
            sys.argv = _argv
Ejemplo n.º 16
0
    def test_glue_environ_bad_name(self, mock_os):
        mock_os.environ = {'FOO_BAR': 2, 'BAZ': 3}
        config = StringIO("[foo]\nbar=1")
        self.parser.readfp(config)

        _argv, sys.argv = sys.argv, ['prognam']
        try:
            op, options, args = schemaconfigglue(self.parser)
            self.assertEqual(self.parser.values(),
                {'foo': {'bar': 1}, '__main__': {'baz': 0}})
        finally:
            sys.argv = _argv
Ejemplo n.º 17
0
 def create_parser(self, prog_name, subcommand):
     """
     Add all our SchemaConfigParser's options so they can be shown
     in help messages and such.
     """
     parser = OptionParser(prog=prog_name,
                           usage=self.usage(subcommand),
                           version=self.get_version(),
                           option_list=self.option_list)
     configglue_parser = settings.__CONFIGGLUE_PARSER__
     op, options, args = schemaconfigglue(configglue_parser, op=parser)
     return op
Ejemplo n.º 18
0
    def get_options(self):
        '''With this method we will be pre-parsing options for our program,
        basically it is a parser to re-use configglue in the vauxoo's way, with
        the minimal configuration for our scripts, une time you instance the
        VauxooTools class in your script you will have available the minimal
        config parameter to be used against any openerp instance avoiding the
        need to re-implement the wheel any time you write a xml-rpc script with
        any of the tools availables.

        Instanciate the config in your application.

        >>> configuration = VauxooTools(app_name='TestApi',
        ...                             options=['hostname', 'port'])

        Ask for options.

        >>> result = configuration.get_options()
        >>> print result
        {'hostname': 'localhost', 'port': 8069, 'args': []}

        Where args will be the parameter passed to your script use it to
        receive parameters from the console.

        If you don't pass options you will receive an empty dict, with only the
        args key, you will need to valid both in your code to ensure it is
        empty if you need it.

        >>> configuration = VauxooTools(app_name='TestApi')
        >>> result = configuration.get_options()
        >>> print result
        {'args': []}
        '''
        result = {}
        options = self.options
        self.scp.read(self.appconfig.config.get_config_files(self.appconfig))
        opt, opts, args = glue.schemaconfigglue(self.scp)
        self.logger.info(opts)
        is_valid, reasons = self.scp.is_valid(report=True)
        if not is_valid:
            opt.error(reasons[0])
        values = self.scp.values('__main__')
        if options is not None:
            if self.log:
                options.append('logfile')
                options.append('loglevel')
            for option in options:
                value = values.get(option)
                result[option] = value
        else:
            pass
        result['args'] = args
        return result
Ejemplo n.º 19
0
    def get_options(self):
        '''With this method we will be pre-parsing options for our program,
        basically it is a parser to re-use configglue in the vauxoo's way, with
        the minimal configuration for our scripts, une time you instance the
        VauxooTools class in your script you will have available the minimal
        config parameter to be used against any openerp instance avoiding the
        need to re-implement the wheel any time you write a xml-rpc script with
        any of the tools availables.

        Instanciate the config in your application.

        >>> configuration = VauxooTools(app_name='TestApi',
        ...                             options=['hostname', 'port'])

        Ask for options.

        >>> result = configuration.get_options()
        >>> print result
        {'hostname': 'localhost', 'port': 8069, 'args': []}

        Where args will be the parameter passed to your script use it to
        receive parameters from the console.

        If you don't pass options you will receive an empty dict, with only the
        args key, you will need to valid both in your code to ensure it is
        empty if you need it.

        >>> configuration = VauxooTools(app_name='TestApi')
        >>> result = configuration.get_options()
        >>> print result
        {'args': []}
        '''
        result = {}
        options = self.options
        self.scp.read(self.appconfig.config.get_config_files(self.appconfig))
        opt, opts, args = glue.schemaconfigglue(self.scp)
        self.logger.info(opts)
        is_valid, reasons = self.scp.is_valid(report=True)
        if not is_valid:
            opt.error(reasons[0])
        values = self.scp.values('__main__')
        if options is not None:
            if self.log:
                options.append('logfile')
                options.append('loglevel')
            for option in options:
                value = values.get(option)
                result[option] = value
        else:
            pass
        result['args'] = args
        return result
Ejemplo n.º 20
0
    def test_glue_environ_precedence_null_and_fatal_option(self):
        class MySchema(Schema):
            foo = StringOption(null=True, fatal=True)

        parser = SchemaConfigParser(MySchema())

        with patch.object(os, 'environ', {'CONFIGGLUE_FOO': '42'}):
            _argv, sys.argv = sys.argv, ['prognam']
            try:
                op, options, args = schemaconfigglue(parser)
                self.assertEqual(parser.get('__main__', 'foo'), '42')
            finally:
                sys.argv = _argv
Ejemplo n.º 21
0
    def test_glue_environ_precedence_null_and_fatal_option(self):
        class MySchema(Schema):
            foo = StringOption(null=True, fatal=True)

        parser = SchemaConfigParser(MySchema())

        with patch.object(os, 'environ', {'CONFIGGLUE_FOO': '42'}):
            _argv, sys.argv = sys.argv, ['prognam']
            try:
                op, options, args = schemaconfigglue(parser)
                self.assertEqual(parser.get('__main__', 'foo'), '42')
            finally:
                sys.argv = _argv
Ejemplo n.º 22
0
    def test_glue_environ_precedence(self):
        with patch.object(os, 'environ',
            {'CONFIGGLUE_FOO_BAR': '42', 'BAR': '1'}):

            config = StringIO("[foo]\nbar=$BAR")
            self.parser.readfp(config)

            _argv, sys.argv = sys.argv, ['prognam']
            try:
                op, options, args = schemaconfigglue(self.parser)
                self.assertEqual(self.parser.get('foo', 'bar'), 42)
            finally:
                sys.argv = _argv
Ejemplo n.º 23
0
    def execute(self):
        """
        Given the command-line arguments, this figures out which subcommand is
        being run, creates a parser appropriate to that command, and runs it.
        """
        # Preprocess options to extract --settings and --pythonpath.
        # These options could affect the commands that are available, so they
        # must be processed early.
        parser = LaxOptionParser(usage="%prog subcommand [options] [args]",
                                 version=django.get_version(),
                                 option_list=BaseCommand.option_list)
        try:
            configglue_parser = settings.__CONFIGGLUE_PARSER__
            parser, options, args = schemaconfigglue(configglue_parser,
                                                     op=parser,
                                                     argv=self.argv)
            # remove schema-related options from the argv list
            self.argv = args
            utils.update_settings(configglue_parser, settings)
        except AttributeError:
            # no __CONFIGGLUE_PARSER__ found, fall back to standard django
            # options parsing
            options, args = parser.parse_args(self.argv)
            handle_default_options(options)
        except:
            # Ignore any option errors at this point.
            args = self.argv

        try:
            subcommand = self.argv[1]
        except IndexError:
            sys.stderr.write("Type '%s help' for usage.\n" % self.prog_name)
            sys.exit(1)

        if subcommand == 'help':
            if len(args) > 2:
                self.fetch_command(args[2]).print_help(self.prog_name, args[2])
            else:
                parser.print_lax_help()
                sys.stderr.write(self.main_help_text() + '\n')
                sys.exit(1)
        # Special-cases: We want 'django-admin.py --version' and
        # 'django-admin.py --help' to work, for backwards compatibility.
        elif self.argv[1:] == ['--version']:
            # LaxOptionParser already takes care of printing the version.
            pass
        elif self.argv[1:] == ['--help']:
            parser.print_lax_help()
            sys.stderr.write(self.main_help_text() + '\n')
        else:
            self.fetch_command(subcommand).run_from_argv(self.argv)
Ejemplo n.º 24
0
    def test_glue_no_argv(self):
        """Test schemaconfigglue with the default argv value."""
        config = StringIO("[__main__]\nbaz=1")
        self.parser.readfp(config)
        self.assertEqual(self.parser.values(),
            {'foo': {'bar': 0}, '__main__': {'baz': 1}})

        _argv, sys.argv = sys.argv, []
        try:
            op, options, args = schemaconfigglue(self.parser)
            self.assertEqual(self.parser.values(),
                {'foo': {'bar': 0}, '__main__': {'baz': 1}})
        finally:
            sys.argv = _argv
Ejemplo n.º 25
0
    def execute(self):
        """
        Given the command-line arguments, this figures out which subcommand is
        being run, creates a parser appropriate to that command, and runs it.
        """
        # Preprocess options to extract --settings and --pythonpath.
        # These options could affect the commands that are available, so they
        # must be processed early.
        parser = LaxOptionParser(usage="%prog subcommand [options] [args]",
                                 version=django.get_version(),
                                 option_list=BaseCommand.option_list)
        try:
            configglue_parser = settings.__CONFIGGLUE_PARSER__
            parser, options, args = schemaconfigglue(configglue_parser,
                op=parser, argv=self.argv)
            # remove schema-related options from the argv list
            self.argv = args
            utils.update_settings(configglue_parser, settings)
        except AttributeError:
            # no __CONFIGGLUE_PARSER__ found, fall back to standard django
            # options parsing
            options, args = parser.parse_args(self.argv)
            handle_default_options(options)
        except:
            # Ignore any option errors at this point.
            args = self.argv

        try:
            subcommand = self.argv[1]
        except IndexError:
            sys.stderr.write("Type '%s help' for usage.\n" % self.prog_name)
            sys.exit(1)

        if subcommand == 'help':
            if len(args) > 2:
                self.fetch_command(args[2]).print_help(self.prog_name, args[2])
            else:
                parser.print_lax_help()
                sys.stderr.write(self.main_help_text() + '\n')
                sys.exit(1)
        # Special-cases: We want 'django-admin.py --version' and
        # 'django-admin.py --help' to work, for backwards compatibility.
        elif self.argv[1:] == ['--version']:
            # LaxOptionParser already takes care of printing the version.
            pass
        elif self.argv[1:] == ['--help']:
            parser.print_lax_help()
            sys.stderr.write(self.main_help_text() + '\n')
        else:
            self.fetch_command(subcommand).run_from_argv(self.argv)
Ejemplo n.º 26
0
    def test_glue_json_dict(self):
        class MySchema(Schema):
            foo = DictOption()

        parser = SchemaConfigParser(MySchema())
        op, options, args = schemaconfigglue(parser,
                                             argv=['--foo', '{"bar": "baz"}'])

        self.assertEqual(options, {'foo': '{"bar": "baz"}'})
        self.assertEqual(parser.values(),
                         {'__main__': {
                             'foo': {
                                 'bar': 'baz'
                             }
                         }})
Ejemplo n.º 27
0
    def test_glue_environ_precedence(self):
        with patch.object(os, 'environ', {
                'CONFIGGLUE_FOO_BAR': '42',
                'BAR': '1'
        }):

            config = StringIO("[foo]\nbar=$BAR")
            self.parser.readfp(config)

            _argv, sys.argv = sys.argv, ['prognam']
            try:
                op, options, args = schemaconfigglue(self.parser)
                self.assertEqual(self.parser.get('foo', 'bar'), 42)
            finally:
                sys.argv = _argv
Ejemplo n.º 28
0
 def execute(self):
     """Override the base class to handle the schema-related options. """
     configglue_parser = getattr(settings, '__CONFIGGLUE_PARSER__', None)
     if configglue_parser is not None:
         # We need a lax option parser that:
         # - allows the '%prog subcommand [options] [args]' format
         # - will receive the schema options from configglue
         # - doesn't attempt to recognize django options
         lax_parser = LaxOptionParser(
             usage="%prog subcommand [options] [args]")
         parser, options, args = schemaconfigglue(
             configglue_parser, op=lax_parser, argv=self.argv)
         utils.update_settings(configglue_parser, settings)
         # remove schema-related options from the argv list
         self.argv = args
     super(GlueManagementUtility, self).execute()
Ejemplo n.º 29
0
 def execute(self):
     """Override the base class to handle the schema-related options. """
     configglue_parser = getattr(settings, '__CONFIGGLUE_PARSER__', None)
     if configglue_parser is not None:
         # We need a lax option parser that:
         # - allows the '%prog subcommand [options] [args]' format
         # - will receive the schema options from configglue
         # - doesn't attempt to recognize django options
         lax_parser = LaxOptionParser(
             usage="%prog subcommand [options] [args]")
         parser, options, args = schemaconfigglue(configglue_parser,
                                                  op=lax_parser,
                                                  argv=self.argv)
         utils.update_settings(configglue_parser, settings)
         # remove schema-related options from the argv list
         self.argv = args
     super(GlueManagementUtility, self).execute()
Ejemplo n.º 30
0
    def test_glue_missing_section(self):
        """Test schemaconfigglue with missing section."""
        class MySchema(Schema):
            foo = DictOption()

        config = StringIO("[__main__]\nfoo = bar")
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)

        # hitting the parser directly raises an exception
        self.assertRaises(NoSectionError, parser.values)
        self.assertFalse(parser.is_valid())

        # which is nicely handled by the glue code, so as not to crash it
        op, options, args = schemaconfigglue(parser)

        # there is no value for 'foo' due to the missing section
        self.assertEqual(options, {'foo': None})
Ejemplo n.º 31
0
    def test_glue_environ_bad_name(self, mock_os):
        mock_os.environ = {'FOO_BAR': 2, 'BAZ': 3}
        config = StringIO("[foo]\nbar=1")
        self.parser.readfp(config)

        _argv, sys.argv = sys.argv, ['prognam']
        try:
            op, options, args = schemaconfigglue(self.parser)
            self.assertEqual(self.parser.values(), {
                'foo': {
                    'bar': 1
                },
                '__main__': {
                    'baz': 0
                }
            })
        finally:
            sys.argv = _argv
Ejemplo n.º 32
0
    def test_ambiguous_option(self):
        """Test schemaconfigglue when an ambiguous option is specified."""
        class MySchema(Schema):
            class foo(Section):
                baz = IntOption()

            class bar(Section):
                baz = IntOption()

        config = StringIO("[foo]\nbaz=1")
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)
        self.assertEqual(parser.values('foo'), {'baz': 1})
        self.assertEqual(parser.values('bar'), {'baz': 0})

        op, options, args = schemaconfigglue(parser, argv=['--bar_baz', '2'])
        self.assertEqual(parser.values('foo'), {'baz': 1})
        self.assertEqual(parser.values('bar'), {'baz': 2})
Ejemplo n.º 33
0
    def test_glue_missing_section(self):
        """Test schemaconfigglue with missing section."""
        class MySchema(Schema):
            foo = DictOption()

        config = StringIO("[__main__]\nfoo = bar")
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)

        # hitting the parser directly raises an exception
        self.assertRaises(NoSectionError, parser.values)
        self.assertFalse(parser.is_valid())

        # which is nicely handled by the glue code, so as not to crash it
        op, options, args = schemaconfigglue(parser)

        # there is no value for 'foo' due to the missing section
        self.assertEqual(options, {'foo': None})
Ejemplo n.º 34
0
    def test_ambiguous_option(self):
        """Test schemaconfigglue when an ambiguous option is specified."""
        class MySchema(Schema):
            class foo(Section):
                baz = IntOption()

            class bar(Section):
                baz = IntOption()

        config = StringIO("[foo]\nbaz=1")
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)
        self.assertEqual(parser.values('foo'), {'baz': 1})
        self.assertEqual(parser.values('bar'), {'baz': 0})

        op, options, args = schemaconfigglue(
            parser, argv=['--bar_baz', '2'])
        self.assertEqual(parser.values('foo'), {'baz': 1})
        self.assertEqual(parser.values('bar'), {'baz': 2})
Ejemplo n.º 35
0
    def test_glue_no_op(self):
        """Test schemaconfigglue with the default OptionParser value."""
        config = StringIO("[__main__]\nbaz=1")
        self.parser.readfp(config)
        self.assertEqual(self.parser.values(), {
            'foo': {
                'bar': 0
            },
            '__main__': {
                'baz': 1
            }
        })

        op, options, args = schemaconfigglue(self.parser, argv=['--baz', '2'])
        self.assertEqual(self.parser.values(), {
            'foo': {
                'bar': 0
            },
            '__main__': {
                'baz': 2
            }
        })
Ejemplo n.º 36
0
    def test_glue_section_option(self):
        """Test schemaconfigglue overriding one option."""
        config = StringIO("[foo]\nbar=1")
        self.parser.readfp(config)
        self.assertEqual(self.parser.values(), {
            'foo': {
                'bar': 1
            },
            '__main__': {
                'baz': 0
            }
        })

        op, options, args = schemaconfigglue(self.parser,
                                             argv=['--foo_bar', '2'])
        self.assertEqual(self.parser.values(), {
            'foo': {
                'bar': 2
            },
            '__main__': {
                'baz': 0
            }
        })
Ejemplo n.º 37
0
 def test_main(self):
     s = "[__main__]\nbar = 42\n"
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 38
0
def configglue(fileobj, *filenames, **kwargs):
    args = kwargs.pop('args', None)
    parser, opts, args = schemaconfigglue(ini2schema(fileobj), argv=args)
    return IniGlue(parser, opts, args)
Ejemplo n.º 39
0
def configglue(fileobj, *filenames, **kwargs):
    args = kwargs.pop('args', None)
    parser, opts, args = schemaconfigglue(ini2schema(fileobj), argv=args)
    return IniGlue(parser, opts, args)
Ejemplo n.º 40
0
 def test_parser_bool(self):
     s = "[__main__]\nbar = true\nbar.parser = bool \n"
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 41
0
 def test_parser_none(self):
     s = "[__main__]\nbar = meeeeh\nbar.parser = none"
     _, cg, _ = configglue(StringIO(s), extra_parsers=[("none", str)])
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 42
0
 def test_main(self):
     s = "[__main__]\nbar = 42\n"
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 43
0
 def test_empty(self):
     s = ""
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 44
0
 def test_parser_bool(self):
     s = "[__main__]\nbar = true\nbar.parser = bool \n"
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 45
0
 def test_parser_none(self):
     s = "[__main__]\nbar = meeeeh\nbar.parser = none"
     _, cg, _ = configglue(StringIO(s), extra_parsers=[('none', str)])
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))
Ejemplo n.º 46
0
 def test_empty(self):
     s = ""
     _, cg, _ = configglue(StringIO(s))
     _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
     self.assertEqual(vars(cg), vars(sg))