def test_commented(self):
        opt = configdata.Option(name='opt',
                                typ=configtypes.Int(),
                                default='def',
                                backends=[usertypes.Backend.QtWebEngine],
                                raw_backends=None,
                                description='Hello World')
        options = [(None, opt, 'val')]
        bindings = {
            'normal': {
                ',x': 'message-info normal'
            },
            'caret': {
                ',y': 'message-info caret'
            }
        }

        writer = configfiles.ConfigPyWriter(options, bindings, commented=True)
        lines = list(writer._gen_lines())

        assert "## Autogenerated config.py" in lines
        assert "# config.load_autoconfig()" in lines
        assert "# c.opt = 'val'" in lines
        assert "## Bindings for normal mode" in lines
        assert "# config.bind(',x', 'message-info normal')" in lines
        caret_bind = ("# config.bind(',y', 'message-info caret', "
                      "mode='caret')")
        assert caret_bind in lines
    def test_output(self):
        desc = ("This is an option description.\n\n"
                "Nullam eu ante vel est convallis dignissim. Fusce suscipit, "
                "wisi nec facilisis facilisis, est dui fermentum leo, quis "
                "tempor ligula erat quis odio.")
        opt = configdata.Option(name='opt',
                                typ=configtypes.Int(),
                                default='def',
                                backends=[usertypes.Backend.QtWebEngine],
                                raw_backends=None,
                                description=desc)
        options = [(None, opt, 'val')]
        bindings = {
            'normal': {
                ',x': 'message-info normal'
            },
            'caret': {
                ',y': 'message-info caret'
            }
        }

        writer = configfiles.ConfigPyWriter(options, bindings, commented=False)
        text = '\n'.join(writer._gen_lines())

        assert text == textwrap.dedent("""
            # Autogenerated config.py
            #
            # NOTE: config.py is intended for advanced users who are comfortable
            # with manually migrating the config file on qutebrowser upgrades. If
            # you prefer, you can also configure qutebrowser using the
            # :set/:bind/:config-* commands without having to write a config.py
            # file.
            #
            # Documentation:
            #   qute://help/configuring.html
            #   qute://help/settings.html

            # Uncomment this to still load settings configured via autoconfig.yml
            # config.load_autoconfig()

            # This is an option description.  Nullam eu ante vel est convallis
            # dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui
            # fermentum leo, quis tempor ligula erat quis odio.
            # Type: Int
            c.opt = 'val'

            # Bindings for normal mode
            config.bind(',x', 'message-info normal')

            # Bindings for caret mode
            config.bind(',y', 'message-info caret', mode='caret')
        """).lstrip()
Beispiel #3
0
def gen_classes():
    for _name, member in inspect.getmembers(configtypes, inspect.isclass):
        if member is configtypes.BaseType:
            pass
        elif member is configtypes.MappingType:
            pass
        elif member is configtypes.List:
            yield functools.partial(member, inner_type=configtypes.Int())
            yield functools.partial(member, inner_type=configtypes.Url())
        elif member is configtypes.FormatString:
            yield functools.partial(member, fields=['a', 'b'])
        elif issubclass(member, configtypes.BaseType):
            yield member
Beispiel #4
0
      ('new-instance-open-target',
       SettingValue(typ.NewInstanceOpenTarget(), 'window'),
       "How to open links in an existing instance if a new one is "
       "launched."),
  )),
 ('ui',
  sect.KeyValue(
      ('zoom-levels',
       SettingValue(
           typ.PercList(minval=0),
           '25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,200%,'
           '250%,300%,400%,500%'),
       "The available zoom levels, separated by commas."),
      ('default-zoom', SettingValue(typ.Perc(),
                                    '100%'), "The default zoom level."),
      ('message-timeout', SettingValue(typ.Int(), '2000'),
       "Time (in ms) to show messages in the statusbar for."),
      ('confirm-quit', SettingValue(typ.ConfirmQuit(), 'never'),
       "Whether to confirm quitting the application."),
      ('display-statusbar-messages', SettingValue(typ.Bool(), 'false'),
       "Whether to display javascript statusbar messages."),
      ('zoom-text-only', SettingValue(typ.Bool(), 'false'),
       "Whether the zoom factor on a frame applies only to the text or to "
       "all content."),
      ('frame-flattening', SettingValue(typ.Bool(), 'false'),
       "Whether to  expand each subframe to its contents.\n\n"
       "This will flatten all the frames to become one scrollable page."),
      ('user-stylesheet',
       SettingValue(typ.UserStyleSheet(),
                    '::-webkit-scrollbar { width: 0px; height: 0px; }'),
       "User stylesheet to use (absolute filename or CSS string)."),
Beispiel #5
0
         "launched."),
    )),

    ('ui', sect.KeyValue(
        ('zoom-levels',
         SettingValue(typ.PercList(minval=0),
                      '25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,200%,'
                      '250%,300%,400%,500%'),
         "The available zoom levels, separated by commas."),

        ('default-zoom',
         SettingValue(typ.ZoomPerc(), '100%'),
         "The default zoom level."),

        ('message-timeout',
         SettingValue(typ.Int(), '2000'),
         "Time (in ms) to show messages in the statusbar for."),

        ('confirm-quit',
         SettingValue(typ.ConfirmQuit(), 'never'),
         "Whether to confirm quitting the application."),

        ('display-statusbar-messages',
         SettingValue(typ.Bool(), 'false'),
         "Whether to display javascript statusbar messages."),

        ('zoom-text-only',
         SettingValue(typ.Bool(), 'false'),
         "Whether the zoom factor on a frame applies only to the text or to "
         "all content."),