Tools for easy persistance of configuration and user preferences for tools.
Configurations are split into sections and keys; sections are conceptually for each tool (or other grouping of settings), and keys are for individual settings within that tool/section. In the current implementation, individual sections are saved within YAML files as a mapping.
# Creating the config object; give it a unique name. Slashes will be # used directly to specify sub-directories. config = metatools.config.Config('your_company/' + __name__) # Use a value within the config; treat it like a dict. dialog = setup_gui(width=config.get('width', 800)) # Save the values later. config['width'] = dialog.width() config.save() # Only if there were changes to the values.
width = metatools.config.get('your_company/' + __name__, 'width') metatools.config.set('your_company/' + __name__, 'width', width)
Mapping which persists to disk via YAML serialization.
Use like a dictionary.
Revert to saved state.
Persist the current contents.
|Parameters:||force (bool) – Always write, even if there were no changes.|
Clear and delete; same as clear() and save().