summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2019-08-29 16:50:12 -0400
committerBrian Potchik <brian@vector35.com>2019-08-29 16:50:12 -0400
commit29c4896cda6e0933a5acb5402ff9ec4fb9ea7e90 (patch)
tree6bfb03a6c579e8df31078253d6ad8cdbaa2ec626 /python
parent6b0c2d2c4c0af274743f12ee523703d624529383 (diff)
Add settings API to query keys and json stringified values.
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py5
-rw-r--r--python/settings.py21
2 files changed, 25 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index a6bb6882..c5d9c363 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -687,7 +687,10 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)):
return settings.Settings(handle=load_settings)
def get_load_settings_for_data(self, data):
- load_settings = core.BNGetBinaryViewLoadSettingsForData(self.handle, data.handle)
+ view_handle = None
+ if data is not None:
+ view_handle = data.handle
+ load_settings = core.BNGetBinaryViewLoadSettingsForData(self.handle, view_handle)
if load_settings is None:
return None
return settings.Settings(handle=load_settings)
diff --git a/python/settings.py b/python/settings.py
index 95501622..66f84fe9 100644
--- a/python/settings.py
+++ b/python/settings.py
@@ -111,6 +111,15 @@ class Settings(object):
def is_empty(self):
return core.BNSettingsIsEmpty(self.handle)
+ def keys(self):
+ length = ctypes.c_ulonglong()
+ result = core.BNSettingsKeysList(self.handle, ctypes.byref(length))
+ out_list = []
+ for i in range(length.value):
+ out_list.append(pyNativeStr(result[i]))
+ core.BNFreeStringList(result, length)
+ return out_list
+
def query_property_string_list(self, key, property_name):
length = ctypes.c_ulonglong()
result = core.BNSettingsQueryPropertyStringList(self.handle, key, property_name, ctypes.byref(length))
@@ -173,6 +182,11 @@ class Settings(object):
core.BNFreeStringList(result, length)
return out_list
+ def get_json(self, key, view = None):
+ if view is not None:
+ view = view.handle
+ return core.BNSettingsGetJsonString(self.handle, key, view, None)
+
def get_bool_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle
@@ -213,6 +227,13 @@ class Settings(object):
core.BNFreeStringList(result, length)
return (out_list, SettingsScope(c_scope.value))
+ def get_json_with_scope(self, key, view = None, scope = SettingsScope.SettingsAutoScope):
+ if view is not None:
+ view = view.handle
+ c_scope = core.SettingsScopeEnum(scope)
+ result = core.BNSettingsGetJsonString(self.handle, key, view, ctypes.byref(c_scope))
+ return (result, SettingsScope(c_scope.value))
+
def set_bool(self, key, value, view = None, scope = SettingsScope.SettingsAutoScope):
if view is not None:
view = view.handle