Add examples for save and get configurations
This commit is contained in:
parent
4b9a5e45a5
commit
2527c60ed0
|
@ -451,3 +451,24 @@ Get digest
|
|||
digest = app.sha512(data)
|
||||
app.msgbox(digest)
|
||||
|
||||
|
||||
Save and get configurations
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can save any data.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
my_app = 'my_extension'
|
||||
data = {
|
||||
'path': '/home/mau/work',
|
||||
'save_data': True,
|
||||
}
|
||||
|
||||
app.set_config('config', data, my_app)
|
||||
|
||||
app.msgbox('Save config')
|
||||
|
||||
data = app.get_config('config', my_app)
|
||||
|
||||
app.msgbox(data)
|
||||
|
|
|
@ -692,8 +692,8 @@ def sha512(data):
|
|||
result = hashlib.sha512(data.encode()).hexdigest()
|
||||
return result
|
||||
|
||||
|
||||
def get_config(key='', default={}, prefix='conf'):
|
||||
# ~ todo
|
||||
def get_config(key='', prefix='conf', default={}):
|
||||
name_file = FILE_NAME_CONFIG.format(prefix)
|
||||
values = None
|
||||
path = _P.join(_P.config('UserConfig'), name_file)
|
||||
|
|
Loading…
Reference in New Issue