Created
February 19, 2014 07:19
-
-
Save Eugeny/9087474 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from reconfigure.items.bound import BoundData | |
from reconfigure.configs.base import Reconfig | |
from reconfigure.parsers import IniFileParser | |
from reconfigure.builders import BoundBuilder | |
class OperaData (BoundData): | |
pass | |
class GlobalData (BoundData): | |
pass | |
OperaData.bind_child('global', lambda x: x.get('global'), item_class=GlobalData) | |
GlobalData.bind_property('option1', 'option1') | |
GlobalData.bind_property('option2', 'option2') | |
class OperaConfig (Reconfig): | |
def __init__(self, **kwargs): | |
k = { | |
'parser': IniFileParser(), | |
'builder': BoundBuilder(OperaData), | |
} | |
k.update(kwargs) | |
Reconfig.__init__(self, **k) | |
# ----------------- | |
config = OperaConfig(path='file.ini') | |
config.load() | |
print config.tree | |
config.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[global] | |
option1=value1 | |
option2=value2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment