2525from __future__ import absolute_import
2626from __future__ import unicode_literals
2727
28- from StringIO import StringIO
28+ from io import StringIO
2929
30- from collections import OrderedDict
3130from functools import partial
3231from itertools import chain
3332from struct import unpack
3635
3736import attr
3837
38+ from commoncode .cliutils import PluggableCommandLineOption as CommandLineOption
39+ from commoncode .cliutils import SCAN_GROUP
3940from commoncode import fileutils
4041from plugincode .scan import ScanPlugin
4142from plugincode .scan import scan_impl
42- from scancode import CommandLineOption
43- from scancode import SCAN_GROUP
43+
4444from typecode import contenttype
4545
4646from sourcecode import kernel
@@ -54,8 +54,8 @@ class JavaClassScanner(ScanPlugin):
5454 """
5555 Scan java class information from the resource.
5656 """
57- resource_attributes = OrderedDict (
58- javaclass = attr .ib (default = attr .Factory (OrderedDict ), repr = False ),
57+ resource_attributes = dict (
58+ javaclass = attr .ib (default = attr .Factory (dict ), repr = False ),
5959 )
6060
6161 options = [
@@ -81,17 +81,17 @@ def scan_javaclass(location, **kwargs):
8181 if not T .is_java_class :
8282 return
8383
84- javaclass_data = OrderedDict ()
84+ javaclass_data = dict ()
8585 SHOW_CONSTS = 1
8686 data = open (location , 'rb' ).read ()
8787 f = StringIO (data )
8888 c = javaclass .Class (f )
89-
90- javaclass_data ['Version' ] = 'Version: %i.%i (%s)' % ( c .version [1 ], c .version [0 ], getJavacVersion (c .version ))
89+
90+ javaclass_data ['Version' ] = 'Version: %i.%i (%s)' % (c .version [1 ], c .version [0 ], getJavacVersion (c .version ))
9191
9292 if SHOW_CONSTS :
9393 javaclass_data ['Constants Pool' ] = str (len (c .constants ))
94- constants = OrderedDict ()
94+ constants = dict ()
9595 for i in range (1 , len (c .constants )):
9696 const = c .constants [i ]
9797
@@ -100,7 +100,7 @@ def scan_javaclass(location, **kwargs):
100100 # double and long constants take 2 slots, we must skip the 'None' one
101101 if not const : continue
102102
103- constant_data = OrderedDict ()
103+ constant_data = dict ()
104104 if const [0 ] == CONSTANT_Fieldref :
105105 constant_data ['Field' ] = str (c .constants [const [1 ]][1 ])
106106
@@ -111,40 +111,39 @@ def scan_javaclass(location, **kwargs):
111111 constant_data ['InterfaceMethod' ] = str (c .constants [const [1 ]][1 ])
112112
113113 elif const [0 ] == CONSTANT_String :
114- constant_data ['String' ] = str (const [1 ])
114+ constant_data ['String' ] = str (const [1 ])
115115
116116 elif const [0 ] == CONSTANT_Float :
117- constant_data ['Float' ] = str (const [1 ])
117+ constant_data ['Float' ] = str (const [1 ])
118118
119119 elif const [0 ] == CONSTANT_Integer :
120- constant_data ['Integer' ] = str (const [1 ])
120+ constant_data ['Integer' ] = str (const [1 ])
121121
122122 elif const [0 ] == CONSTANT_Double :
123- constant_data ['Double' ] = str (const [1 ])
123+ constant_data ['Double' ] = str (const [1 ])
124124
125125 elif const [0 ] == CONSTANT_Long :
126- constant_data ['Long' ] = str (const [1 ])
126+ constant_data ['Long' ] = str (const [1 ])
127127
128128 # elif const[0] == CONSTANT_NameAndType:
129129 # print 'NameAndType\t\t FIXME!!!'
130130
131131 elif const [0 ] == CONSTANT_Utf8 :
132- constant_data ['Utf8' ] = str (const [1 ])
132+ constant_data ['Utf8' ] = str (const [1 ])
133133
134134 elif const [0 ] == CONSTANT_Class :
135- constant_data ['Class' ] = str (c .constants [const [1 ]][1 ])
135+ constant_data ['Class' ] = str (c .constants [const [1 ]][1 ])
136136
137137 elif const [0 ] == CONSTANT_NameAndType :
138- constant_data ['NameAndType' ] = str (const [1 ]) + ', ' + str (const [2 ])
138+ constant_data ['NameAndType' ] = str (const [1 ]) + ', ' + str (const [2 ])
139139 else :
140140 constant_data ['Unknown(' + str (const [0 ]) + ')' ] = str (const [1 ])
141-
141+
142142 constants [i ] = constant_data
143-
144- javaclass_data ['Constants' ] = constants
145143
144+ javaclass_data ['Constants' ] = constants
146145
147- access = []
146+ access = []
148147 if c .access & ACC_INTERFACE :
149148 access .append ('Interface ' )
150149 if c .access & ACC_SUPER_OR_SYNCHRONIZED :
@@ -173,7 +172,7 @@ def scan_javaclass(location, **kwargs):
173172 interfaces .append (str (inter ))
174173 if interfaces :
175174 javaclass_data ['Interfaces' ] = interfaces
176-
177- return OrderedDict (
175+
176+ return dict (
178177 javaclass = javaclass_data ,
179178 )
0 commit comments