# -*- coding: iso-8859-1 -*- from kaa.config import Var, Group, Dict, Config config = Config(desc='mplayer configuration', schema=[ Var(name='activate', desc='activate backend', default=True), Dict(name='dict', schema=Var(default=''), defaults={ 'x': 'foo', 'y': 'yyy' }), Dict(name='dictgroup', schema=Group(schema=[ Var(name='x', default=True), Var(name='y', default=True) ])), Dict(name='dictdict', schema=Dict(name='foo', schema=Var(default=''))) ]) config.dict['f'] = 'd' config.dict['z'] = 'j' config.dictdict['a']['f'] = 'd' config.dictdict['b']['z'] = 'j' config.dictgroup['c'].x = False config.dictgroup['d'].y = 'j'
# -*- coding: iso-8859-1 -*- from kaa.config import Var, Group, Dict, List, Config def config_change_cb(name, oldval, newval): print "******* CFG ITEM CHANGE", name, oldval, newval config = Config(desc='basic config group', schema=[ Var(name='foo', desc='some text', default=5), Var(name='bar', default=u'bar', desc='more text\ndescription has two lines'), # group defined inside the basic schema Group(name='inline', desc='this is a subgroup', schema=[ Var(name='x', desc='desc_x', default=7 ), Var(name='y', type=range(0,5), desc='desc_y', default=3 ) ]) ]) # create extra group and add it to the schema subgroup = Group(desc='this is a subgroup', schema=[ Var(name='x', desc=u'desc_x with non ascii ü', default=7 ), # the next variable allows numbers from 0-4 Var(name='y', type=range(0,5), desc='desc_y', default=3 ) ]) config.add_variable('subgroup', subgroup) # create a group again deeper in the tree subsubgroup = Group(desc='desrc of subsubgroup', schema=[ Var(name='a', desc='desc a', default=3 ) ]) subgroup.add_variable('z', subsubgroup)
import os import socket import logging # kaa imports import kaa from kaa.config import Config, Group, Var # tvdev imports from device import DVBCard # get logging object log = logging.getLogger('tvdev') # config object config = Config(schema=[]) rpcgroup = Group(desc='Remote access to the server', schema=[ Var(name='address', default='127.0.0.1:7600', desc='IP address and port to use for inter-process communication'), Var(name='password', default='', desc='Password to secure the communication')]) config.add_variable(name='rpc', value=rpcgroup) config.add_variable(name='directory', value=Var(default=os.path.expanduser('~/Videos'), desc='Default recording directory')) # list of detected cards log.info('Detecting DVB cards.') info = [] for i in range(10): if os.path.isdir('/dev/dvb/adapter%s' % i): try:
# -*- coding: iso-8859-1 -*- from kaa.config import Var, Group, Dict, Config config = Config(desc='mplayer configuration', schema=[ Var(name='activate', desc='activate backend', default=True), Dict(name='dict', schema=Var(default=''), defaults = {'x': 'foo', 'y': 'yyy'}), Dict(name='dictgroup', schema=Group(schema = [ Var(name='x', default=True), Var(name='y', default=True)])), Dict(name='dictdict', schema=Dict(name='foo', schema=Var(default=''))) ]) config.dict['f'] = 'd' config.dict['z'] = 'j' config.dictdict['a']['f'] = 'd' config.dictdict['b']['z'] = 'j' config.dictgroup['c'].x = False config.dictgroup['d'].y = 'j' print config.dictdict['a']['f'] print 'save' config.save('x.cfg')
import os import socket import logging # kaa imports import kaa from kaa.config import Config, Group, Var # tvdev imports from device import DVBCard # get logging object log = logging.getLogger('tvdev') # config object config = Config(schema=[]) rpcgroup = Group( desc='Remote access to the server', schema=[ Var(name='address', default='127.0.0.1:7600', desc='IP address and port to use for inter-process communication'), Var(name='password', default='', desc='Password to secure the communication') ]) config.add_variable(name='rpc', value=rpcgroup) config.add_variable(name='directory', value=Var(default=os.path.expanduser('~/Videos'), desc='Default recording directory'))