Exemplo n.º 1
0
    def __init__(self, connector=None):
        """user configuration:
            hidden values can not be set by the user in the options,
            but might be subject of being set automatically, e.g. the
            heartbeat.
        """
        db.require(DBNAME, '0')
        c = cfg.ConfigBuilder()
        with c['keyboard_shortcuts'] as kbs:
            kbs.valid = '\d\d?\d?'
            kbs['prev'].value = 89
            kbs['play'].value = 88
            kbs['pause'].value = 67
            kbs['stop'].value = 86
            kbs['next'].value = 66
            kbs['search'].value = 83
        with c['misc.show_playlist_download_buttons'] as pl_download_buttons:
            pl_download_buttons.value = False
        with c['misc.autoplay_on_add'] as autoplay_on_add:
            autoplay_on_add.value = False
        with c['custom_theme.primary_color'] as primary_color:
            primary_color.value = '#F02E75'
            primary_color.valid = '#[0-9a-fA-F]{6}'
        with c['custom_theme.white_on_black'] as white_on_black:
            white_on_black.value = False
        with c['last_time_online'] as last_time_online:
            last_time_online.value = 0
            last_time_online.valid = '\\d+'
            last_time_online.hidden = True
            last_time_online.doc = "UNIX TIME (1.1.1970 = never)"

        self.DEFAULTS = c.to_configuration()

        self.conn = BoundConnector(DBNAME, connector).connection()
Exemplo n.º 2
0
    def test_inheritance_of_property_attributes(self):
        cb = cfg.ConfigBuilder()
        with cb['parent'] as parent:
            parent.valid = '.*'
            parent.readonly = True
            parent.hidden = True
            with parent['child'] as child:
                child.value = 4

        childprop = cb.to_configuration().property('parent.child')

        assert '.*' == childprop.valid
        assert childprop.readonly
        assert childprop.hidden
Exemplo n.º 3
0
    def test_builder(self):
        properties = [Property('a', 5), Property('a.b', 6, int, '6.*', True, True, 'doc')]
        cb = cfg.ConfigBuilder()

        with cb['a'] as a:
            a.value = 5
            with a['b'] as ab:
                ab.value = 6
                ab.valid = '6.*'
                ab.readonly = True
                ab.hidden = True
                ab.doc = 'doc'

        assert properties == list(cb.to_configuration().to_properties())