diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2020-11-10 22:46:45 -0500 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2020-11-10 22:47:23 -0500 |
| commit | b2f8c2f482fdb7867a100e693e63d096e39094ad (patch) | |
| tree | a5b5069ebd5c063869f49af043d8d80a9501fc54 /python/settings.py | |
| parent | c1da063a1b6e627212414fe7896fd964b0e3532a (diff) | |
documentation update, example for settings and description of using custom convention in type docs
Diffstat (limited to 'python/settings.py')
| -rw-r--r-- | python/settings.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/python/settings.py b/python/settings.py index 0bf0686f..8bb87f80 100644 --- a/python/settings.py +++ b/python/settings.py @@ -60,6 +60,29 @@ class Settings(object): Individual settings are identified by a key, which is a string in the form of **'<group>.<name>'**. Groups provide a simple way \ to categorize settings. Additionally, sub-categories can be expressed directly in the name part of the key with a similar dot notation. + + Here's a simple example using a Resource Scope to cause settings to be saved inside of a BNDB when saved: + + >>> bv2 = open_view("/tmp/ls") + >>> plugin_settings = Settings() + >>> description = "Tells Zhu Li to do the thing." + >>> title = "Do the thing" + >>> schema = f'{{"description" : "{description}", "title" : "{title}", "default" : true, "type" : "boolean"}}' + >>> plugin_settings.register_setting("ui.dothething", schema) + True + >>> plugin_settings.set_bool("ui.dothething", False, bv, SettingsScope.SettingsResourceScope) + True + >>> # Resource scope will save the setting in the BNDB itself + >>> bv2.create_database("/tmp/ls.bndb") + True + >>> bv = open_view("/tmp/ls") + >>> # If in a plugin we would need to make sure we re-regsitered the setting before querying + >>> plugin_settings.get_bool("ui.dothething", bv) + True + >>> bv = binaryninja.open_view("/tmp/ls.bndb") + >>> plugin_settings.get_bool("ui.dothething", bv) + False + """ handle = core.BNCreateSettings("default") |
