Skip to content

Commit

Permalink
Added ability to toggle binary flags through the python calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vagrant committed May 10, 2017
1 parent 62e9caa commit bacdb57
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/binwalk/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,19 +665,23 @@ def __enter__(self):
def __exit__(self, t, v, b):
self.cleanup()

def _set_arguments(self, argv=[], kargv={}):
for (k, v) in iterator(kargv):
k = self._parse_api_opt(k)
if v not in [True, False, None]:
if not isinstance(v, list):
v = [v]
for value in v:
if not isinstance(value, str):
value = str(bytes2str(value))
argv.append(k)
argv.append(value)
else:
argv.append(k)
def _set_arguments(self, argv=None, kargv=None):
if kargv:
for (k, v) in iterator(kargv):
k = self._parse_api_opt(k)
if v not in [True, False, None]:
if not isinstance(v, list):
v = [v]
for value in v:
if not isinstance(value, str):
value = str(bytes2str(value))
argv.append(k)
argv.append(value)
else:
# Only append if the value is True; this allows for toggling values
# by the function call.
if v:
argv.append(k)

if not argv and not self.arguments:
self.arguments = sys.argv[1:]
Expand Down

0 comments on commit bacdb57

Please sign in to comment.