SCRIPTS MODULES module_user_settingsΒΆ

# -*-Python-*-
# Created by meneghini at 17 Nov 2017  11:45

# Create a new module
OMFIT['asd'] = mod = OMFITmodule(None)
# set module ID
mod['SETTINGS']['MODULE']['ID'] = 'test_module'

# Add something to the settings
mod['SETTINGS']['PHYSICS']['var'] = 1
print(mod['SETTINGS']['PHYSICS']['var'])

# Save current users settings (default save name is `__default__`)
mod.saveUserSettings()

# Modify settings
mod['SETTINGS']['PHYSICS']['var'] = 2
print(mod['SETTINGS']['PHYSICS']['var'])

# Save current users settings with different name
mod.saveUserSettings(variant='test')

# reload original settings
mod.loadUserSettings()
print(mod['SETTINGS']['PHYSICS']['var'])

# list variants
mod.listUserSettings(verbose=True)

# delete users settings
for item in mod.listUserSettings():
    mod.deleteUserSettings(item)