(self)
return(configspec)
Convert our tree of default values into a ConfigObj validation
        specification
Convert our tree of default values into a ConfigObj validation
        specification
Convert our tree of default values into a ConfigObj validation specification
def defaults_to_configspec(self):
        """Convert our tree of default values into a ConfigObj validation
        specification"""
        configspecdata = {}

        keymap = {
                'int': 'integer',
                'str': 'string',
                'bool': 'boolean',
                }

        section = {}
        for key in DEFAULTS['global_config']:
            keytype = DEFAULTS['global_config'][key].__class__.__name__
            value = DEFAULTS['global_config'][key]
            if keytype in keymap:
                keytype = keymap[keytype]
            elif keytype == 'list':
                value = 'list(%s)' % ','.join(value)

            keytype = '%s(default=%s)' % (keytype, value)

            if key == 'custom_url_handler':
                keytype = 'string(default="")'

            section[key] = keytype
        configspecdata['global_config'] = section

        section = {}
        for key in DEFAULTS['keybindings']:
            value = DEFAULTS['keybindings'][key]
            if value is None or value == '':
                continue
            section[key] = 'string(default=%s)' % value
        configspecdata['keybindings'] = section

        section = {}
        for key in DEFAULTS['profiles']['default']:
            keytype = DEFAULTS['profiles']['default'][key].__class__.__name__
            value = DEFAULTS['profiles']['default'][key]
            if keytype in keymap:
                keytype = keymap[keytype]
            elif keytype == 'list':
                value = 'list(%s)' % ','.join(value)
            if keytype == 'string':
                value = '"%s"' % value

            keytype = '%s(default=%s)' % (keytype, value)

            section[key] = keytype
        configspecdata['profiles'] = {}
        configspecdata['profiles']['__many__'] = section

        section = {}
        section['type'] = 'string'
        section['parent'] = 'string'
        section['profile'] = 'string(default=default)'
        section['command'] = 'string(default="")'
        section['position'] = 'string(default="")'
        section['size'] = 'list(default=list(-1,-1))'
        configspecdata['layouts'] = {}
        configspecdata['layouts']['__many__'] = {}
        configspecdata['layouts']['__many__']['__many__'] = section

        configspecdata['plugins'] = {}

        configspec = ConfigObj(configspecdata)
        if DEBUG == True:
            configspec.write(open('/tmp/terminator_configspec_debug.txt', 'wb'))
        return(configspec)
def defaults_to_configspec ( self ) : configspecdata = { } keymap = { 'int' : 'integer' , 'str' : 'string' , 'bool' : 'boolean' , } section = { } for key in DEFAULTS [ 'global_config' ] : keytype = DEFAULTS [ 'global_config' ] [ key ] . __class__ . __name__ value = DEFAULTS [ 'global_config' ] [ key ] if keytype in keymap : keytype = keymap [ keytype ] elif keytype == 'list' : value = 'list(%s)' % ',' . join ( value ) keytype = '%s(default=%s)' % ( keytype , value ) if key == 'custom_url_handler' : keytype = 'string(default="")' section [ key ] = keytype configspecdata [ 'global_config' ] = section section = { } for key in DEFAULTS [ 'keybindings' ] : value = DEFAULTS [ 'keybindings' ] [ key ] if value is None or value == '' : continue section [ key ] = 'string(default=%s)' % value configspecdata [ 'keybindings' ] = section section = { } for key in DEFAULTS [ 'profiles' ] [ 'default' ] : keytype = DEFAULTS [ 'profiles' ] [ 'default' ] [ key ] . __class__ . __name__ value = DEFAULTS [ 'profiles' ] [ 'default' ] [ key ] if keytype in keymap : keytype = keymap [ keytype ] elif keytype == 'list' : value = 'list(%s)' % ',' . join ( value ) if keytype == 'string' : value = '"%s"' % value keytype = '%s(default=%s)' % ( keytype , value ) section [ key ] = keytype configspecdata [ 'profiles' ] = { } configspecdata [ 'profiles' ] [ '__many__' ] = section section = { } section [ 'type' ] = 'string' section [ 'parent' ] = 'string' section [ 'profile' ] = 'string(default=default)' section [ 'command' ] = 'string(default="")' section [ 'position' ] = 'string(default="")' section [ 'size' ] = 'list(default=list(-1,-1))' configspecdata [ 'layouts' ] = { } configspecdata [ 'layouts' ] [ '__many__' ] = { } configspecdata [ 'layouts' ] [ '__many__' ] [ '__many__' ] = section configspecdata [ 'plugins' ] = { } configspec = ConfigObj ( configspecdata ) if DEBUG == True : configspec . write ( open ( '/tmp/terminator_configspec_debug.txt' , 'wb' ) ) return ( configspec )