From f229958f0eadd39a37681aa12ffb2ac9d6df60d7 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Thu, 23 May 2019 21:32:09 -0400 Subject: small cleanups from pylint plus fix for analysis_info --- python/basicblock.py | 11 +---------- python/binaryview.py | 37 ++++++++++++------------------------- python/fileaccessor.py | 1 + python/function.py | 10 ---------- python/update.py | 1 + 5 files changed, 15 insertions(+), 45 deletions(-) diff --git a/python/basicblock.py b/python/basicblock.py index 1577ec4f..4a451a38 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -469,7 +469,7 @@ class BasicBlock(object): for i in range(0, count.value): addr = lines[i].addr if (lines[i].instrIndex != 0xffffffffffffffff) and hasattr(self, 'il_function'): - il_instr = self.il_function[lines[i].instrIndex] + il_instr = self.il_function[lines[i].instrIndex] # pylint: disable=no-member else: il_instr = None color = highlight.HighlightColor._from_core_struct(lines[i].highlight) @@ -507,12 +507,3 @@ class BasicBlock(object): if isinstance(color, HighlightStandardColor): color = highlight.HighlightColor(color) core.BNSetUserBasicBlockHighlight(self.handle, color._get_core_struct()) - - @property - def view(self): - """ """ - return self._view - - @view.setter - def view(self, value): - self._view = value diff --git a/python/binaryview.py b/python/binaryview.py index e98be02c..7e2a3d0c 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -162,7 +162,7 @@ class AnalysisCompletionEvent(object): """ def __init__(self, view, callback): self._view = view - self._callback = callback + self.callback = callback self._cb = ctypes.CFUNCTYPE(None, ctypes.c_void_p)(self._notify) self.handle = core.BNAddAnalysisCompletionEvent(self.view.handle, None, self._cb) global _pending_analysis_completion_events @@ -190,7 +190,7 @@ class AnalysisCompletionEvent(object): """ .. warning: This method should only be used when the system is being shut down and no further analysis should be done afterward. """ - self._callback = self._empty_callback + self.callback = self._empty_callback core.BNCancelAnalysisCompletionEvent(self.handle) global _pending_analysis_completion_events if id(self) in _pending_analysis_completion_events: @@ -205,15 +205,6 @@ class AnalysisCompletionEvent(object): def view(self, value): self._view = value - @property - def callback(self): - """ """ - return self._callback - - @callback.setter - def callback(self, value): - self._callback = value - class ActiveAnalysisInfo(object): def __init__(self, func, analysis_time, update_count, submit_count): @@ -290,13 +281,13 @@ class AnalysisInfo(object): self._analysis_time = value @property - def analysis_info(self): + def active_info(self): """ """ - return self._analysis_info + return self._active_info - @analysis_info.setter - def analysis_info(self, value): - self._analysis_info = value + @active_info.setter + def active_info(self, value): + self._active_info = value class AnalysisProgress(object): @@ -715,10 +706,6 @@ class Segment(object): def readable(self): return (core.BNSegmentGetFlags(self.handle) & SegmentFlag.SegmentReadable) != 0 - @property - def end(self): - return core.BNSegmentGetEnd(self.handle) - @property def data_length(self): return core.BNSegmentGetDataLength(self.handle) @@ -945,7 +932,7 @@ class BinaryView(object): _registered = False _registered_cb = None registered_view_type = None - next_address = 0 + _next_address = 0 _associated_data = {} _registered_instances = [] @@ -1347,7 +1334,7 @@ class BinaryView(object): result = [] for i in range(count.value): result.append(types.NameSpace._from_core_struct(nameSpaceList[i])) - core.BNFreeNameSpaceList(nameSpaceList, count.value); + core.BNFreeNameSpaceList(nameSpaceList, count.value) return result @property @@ -3003,7 +2990,7 @@ class BinaryView(object): :rtype: None """ if plat is None: - plat = self.plat + plat = self.platform if plat is not None: plat = plat.handle if sym_type is not None: @@ -4351,7 +4338,7 @@ class BinaryView(object): Evaluates an string expression to an integer value. The parser uses the following rules: - - symbols are defined by the lexer as `[A-Za-z0-9_:<>][A-Za-z0-9_:$\-<>]+` or anything enclosed in either single or + - symbols are defined by the lexer as `[A-Za-z0-9_:<>][A-Za-z0-9_:$\\-<>]+` or anything enclosed in either single or double quotes - Numbers are defaulted to hexadecimal thus `_printf + 10` is equivalent to `printf + 0x10` If decimal numbers required use the decimal prefix. - Since numbers and symbols can be ambiguous its recommended that you prefix your numbers with the following: @@ -5055,7 +5042,7 @@ class StructuredDataView(object): def __getitem__(self, key): m = self._members.get(key, None) if m is None: - return super(StructuredDataView, self).__getitem__(key) + return m ty = m.type offset = m.offset diff --git a/python/fileaccessor.py b/python/fileaccessor.py index 92209793..92d0ef65 100644 --- a/python/fileaccessor.py +++ b/python/fileaccessor.py @@ -23,6 +23,7 @@ import ctypes # Binary Ninja components from binaryninja import _binaryninjacore as core +from binaryninja import log class FileAccessor(object): def __init__(self): diff --git a/python/function.py b/python/function.py index 80e18250..9d70d5be 100644 --- a/python/function.py +++ b/python/function.py @@ -421,16 +421,6 @@ class PossibleValueSet(object): """ """ self._table = value - @property - def table(self): - """ """ - return self._table - - @table.setter - def table(self, value): - """ """ - self._table = value - @property def mapping(self): """ """ diff --git a/python/update.py b/python/update.py index 5f7452df..5bcd9a98 100644 --- a/python/update.py +++ b/python/update.py @@ -23,6 +23,7 @@ import ctypes # Binary Ninja components from binaryninja import _binaryninjacore as core +from binaryninja import log import binaryninja from binaryninja.enums import UpdateResult -- cgit v1.3.1