Add examples for save and get configurations

This commit is contained in:
Mauricio Baeza 2021-06-22 21:56:27 -05:00
parent 4b9a5e45a5
commit 2527c60ed0
2 changed files with 23 additions and 2 deletions

View File

@ -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)

View File

@ -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)