summaryrefslogtreecommitdiff
path: root/python/examples/kaitai/view.py
diff options
context:
space:
mode:
authorAndrew Lamoureux <andrew@vector35.com>2019-03-18 17:31:29 -0400
committerRusty Wagner <rusty@vector35.com>2019-03-20 13:00:17 -0400
commit8e9322ed8b5826dd62bc931d83e0828d42f7969f (patch)
tree4ed5c2611005aa4bf5f892bb98fd3b6b8b5dbc2b /python/examples/kaitai/view.py
parent22be7356f339bcb11383ac0ec2a6e11a605f9533 (diff)
kaitai: gif, jpg, png support and return proper priority
Diffstat (limited to 'python/examples/kaitai/view.py')
-rw-r--r--python/examples/kaitai/view.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/python/examples/kaitai/view.py b/python/examples/kaitai/view.py
index 888049ac..f861b275 100644
--- a/python/examples/kaitai/view.py
+++ b/python/examples/kaitai/view.py
@@ -207,12 +207,28 @@ class KaitaiViewType(ViewType):
# data.file: FileMetadata
# data.raw: BinaryView
- if binaryView == binaryView.file.raw:
- #print 'returning priority=100 for FileView'
- return 100
- else:
- #print 'returning priority 0, not given a raw view'
- return 0
+ priority = 0
+ isExec = binaryView.executable
+ weRecognize = kshelpers.id_data(binaryView.read(0,16)) != None
+
+ # NOTE: ui/shared/hexeditor.cpp has the hex editor at priority 20 when
+ # executable, and 10 otherwise
+
+ if isExec and weRecognize:
+ #print 'priority=25 to slightly beat out the hex editor case=(executable, recognize)'
+ priority = 25
+ if isExec and not weRecognize:
+ #print 'priority=15 to lose to the hex editor case=(executable, !recognize)'
+ priority = 15
+ if not isExec and weRecognize:
+ #print 'priority=100 to beat out everything case=(!executable, recognize)'
+ priority = 100
+ if not isExec and not weRecognize:
+ #print 'priority=5 to lose to hex editor case=(!executable, !recognize)'
+ priority = 5
+
+ #print 'returning priority=%d for KaitaiViewType' % priority
+ return priority
def create(self, binaryView, view_frame):
return KaitaiView(view_frame, binaryView)