Hi,
I've been busy working on the runtime configuration system. Just to see if it is flexible enough to work with.
Some big changes have been made since the last version.
First of all, the newest version can be found at http://www.fambus.nl/~ebus/freevo/runtimexml/v2/
At the moment, the system consists of three files:
a) runtime_config.tpl.fxd - this file goes into your share/fxd directory
b) runtime_config.xml - this file goes into your configuration path (for example /etc/freevo)
c) runtimexml.py - this file goes into your src/config directory
The runtime_config.tpl.fxd file is the heart of the configuration system. It defines the variables that can be changed during runtime. Variables that are not in this file are rejected.
The template file has almost the same structure as the configuration file itself. But there is a difference. The deepest tag in the template is the <var> tag. In the configuration file, the actual data is in this <var> tag.
The <var> tag in the template has two attributes, 'name' and 'types'. For example:
<?xml version="1.0" ?>
<freevo>
<tv>
<var name="channels" types="list|tuple|str" />
</tv>
</freevo>This defines the variable config.TV_CHANNELS. The 'types'-attribute limits the possible values for this variable. Every pipe (|) defines a new level. So, TV_CHANNELS can have a 'list' of 'tuples' containing 'strings'. This could be a valid structure:
<var name="channels">
<list>
<item>
<tuple>
<item>1.tvgids.nl</item>
<item>Nederland 1</item>
<item>E9</item>
</tuple>
</item>
<item>
<tuple>
<item>1.tvgids.nl</item>
<item>Nederland 1</item>
<item>E9</item>
</tuple>
</item>
</list>
</var>This system is not very flexible, because you might want different types for each part of the tuple. At the moment, this is not possible. Depending on the structures we want to save, this could be made possible in the future.
There are three complex structures: 1) <list> 2) <dict> 3) <tuple>
Each structure has <item>-tags which hold the actual information. The <item> tags for the dictionary have an extra attribute 'key'. For example:
<dict> <item key="hello">world</item> <item key="a">dictionary</item> </dict>
Well, that's about it for now. If you want to try out setting some values, use the set_value() method on RuntimeXML. You'll have to supply the method with three parameters:
1) a list with the path to the variable 2) the name of the variable 3) the value of the variable.
For example, to set the config.VIDEO_MPLAYER_AO_DEV variable, you use the following function call:
set_value( ['video','mplayer'], 'ao dev', '/dev/dsp' )
This should do the trick. You can see the result immediatly by reviewing your configuration file. The code contains quite a lot of debug information, so it shouldn't be too hard to see where things go wrong.
Have fun, Eric 'eborn' Bus
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Freevo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-devel
