Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
binwalk
Commits
30216cc8
Commit
30216cc8
authored
Jan 10, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up argparsing code
parent
45486db3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
50 deletions
+2
-50
module.py
src/binwalk/core/module.py
+1
-50
parser.py
src/binwalk/core/parser.py
+1
-0
No files found.
src/binwalk/core/module.py
View file @
30216cc8
...
...
@@ -48,8 +48,6 @@ class Option(object):
def
convert
(
self
,
value
):
if
self
.
type
and
(
self
.
type
.
__name__
==
self
.
dtype
):
return
self
.
type
(
value
)
elif
self
.
type
==
list
:
return
[
value
]
else
:
return
value
...
...
@@ -501,27 +499,6 @@ class ModuleException(Exception):
'''
pass
class
ListActionParser
(
argparse
.
Action
):
'''
Class to handle dictionary argument types.
'''
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
option
=
option_string
.
strip
(
'-'
)
if
has_key
(
parser
.
short_to_long
,
option
):
option
=
parser
.
short_to_long
[
option
]
if
hasattr
(
namespace
,
option
):
current_values
=
getattr
(
namespace
,
option
)
try
:
current_values
.
extend
(
values
)
except
AttributeError
:
current_values
=
values
else
:
current_values
=
values
setattr
(
namespace
,
option
,
current_values
)
class
Modules
(
object
):
'''
Main class used for running and managing modules.
...
...
@@ -741,9 +718,8 @@ class Modules(object):
if
module_option
.
type
is
None
:
parser_kwargs
[
'action'
]
=
'store_true'
elif
module_option
.
type
is
list
:
parser_kwargs
[
'action'
]
=
ListActionParser
parser_kwargs
[
'action'
]
=
'append'
parser
.
short_to_long
[
module_option
.
short
]
=
module_option
.
long
#parser_kwargs['nargs'] = '+'
parser
.
add_argument
(
*
parser_args
,
**
parser_kwargs
)
...
...
@@ -772,9 +748,6 @@ class Modules(object):
# Track the priority for future iterations that may process the same kwarg name
last_priority
[
name
]
=
module_option
.
priority
# If the specified type for these kwargs is None, just set the kwarg to its specified default value.
# Else, set it to the value specified from the user.
#if module_option.type is not None:
try
:
kwargs
[
name
]
=
module_option
.
convert
(
args
[
module_option
.
long
])
except
KeyboardInterrupt
as
e
:
...
...
@@ -782,28 +755,6 @@ class Modules(object):
except
Exception
as
e
:
raise
ModuleException
(
"Invalid usage:
%
s"
%
str
(
e
))
#else:
#value = default_value
# Convert the user-supplied value into the type specified in module_option.type.
# Do this manually as argparse doesn't seem to be able to handle hexadecimal values.
#try:
# Only convert the user-supplied value to a specific type if this kwarg's default
# type is the same as the type specified for the module option.
# if value != default_value and type(default_value) == module_option.type:
# if module_option.type == int:
# kwargs[name] = int(value, 0)
# elif module_option.type == float:
# kwargs[name] = float(value)
# else:
# kwargs[name] = value
# else:
# kwargs[name] = value
#except KeyboardInterrupt as e:
# raise e
#except Exception as e:
# raise ModuleException("Invalid usage: %s" % str(e))
return
kwargs
def
kwargs
(
self
,
obj
,
kwargs
):
...
...
src/binwalk/core/parser.py
View file @
30216cc8
...
...
@@ -70,6 +70,7 @@ class MagicParser(object):
self
.
smart
=
smart
self
.
raw_fd
=
None
self
.
signature_count
=
0
self
.
signature_set
=
set
()
def
__del__
(
self
):
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment