@@ -293,7 +293,7 @@ def _read_content(self, type_code, block_data, class_desc=None):
293293 try :
294294 handler = self .__type_code_handlers [type_code ]
295295 except KeyError :
296- ''' Looking for an external reader'''
296+ """ Looking for an external reader"""
297297 if class_desc and class_desc .data_type == ClassDataType .WRCLASS :
298298 return self ._custom_readObject (class_desc .name )
299299 raise ValueError ("Unknown type code: 0x{0:x}" .format (type_code ))
@@ -327,7 +327,7 @@ def _read_new_string(self, type_code):
327327 raise ValueError ("Invalid string length: {0}" .format (length ))
328328 elif length < 65536 :
329329 self ._log .warning ("Small string stored as a long one" )
330-
330+
331331 # Parse the content
332332 data = self .__fd .read (length )
333333 java_str = JavaString (handle , data )
@@ -356,7 +356,7 @@ def _do_classdesc(self, type_code):
356356 handle = self ._new_handle ()
357357 desc_flags = self .__reader .read_byte ()
358358 nb_fields = self .__reader .read_short ()
359-
359+
360360 if nb_fields < 0 :
361361 raise ValueError ("Invalid field count: {0}" .format (nb_fields ))
362362
@@ -375,9 +375,9 @@ def _do_classdesc(self, type_code):
375375 "Invalid field type char: 0x{0:x}" .format (field_type )
376376 )
377377
378- fields .append (JavaField (
379- FieldType (field_type ), field_name , class_name
380- ))
378+ fields .append (
379+ JavaField ( FieldType (field_type ), field_name , class_name )
380+ )
381381
382382 # Setup the class description bean
383383 class_desc = JavaClassDesc (ClassDescType .NORMALCLASS )
@@ -418,19 +418,19 @@ def _do_classdesc(self, type_code):
418418 # Store the reference to the parsed bean
419419 self ._set_handle (handle , class_desc )
420420 return class_desc
421-
422- raise ValueError ("Expected a valid class description starter" )
423421
422+ raise ValueError ("Expected a valid class description starter" )
424423
425424 def _custom_readObject (self , class_name ):
426425 self .__fd .seek (- 1 , os .SEEK_CUR )
427426 for transformer in self .__transformers :
428- class_data = transformer .load_custom_writeObject (self , self .__reader , class_name )
427+ class_data = transformer .load_custom_writeObject (
428+ self , self .__reader , class_name
429+ )
429430 if class_data :
430431 return class_data
431432 raise ValueError ("Custom readObject can not be processed" )
432-
433-
433+
434434 def _read_class_annotations (self , class_desc = None ):
435435 # type: () -> List[ParsedJavaContent]
436436 """
@@ -494,8 +494,14 @@ def _do_object(self, type_code=0):
494494 return instance
495495
496496 def _is_default_supported (self , class_name ):
497- default_transf = [x for x in self .__transformers if isinstance (x , DefaultObjectTransformer )]
498- return len (default_transf ) and class_name in default_transf [0 ]._type_mapper
497+ default_transf = [
498+ x
499+ for x in self .__transformers
500+ if isinstance (x , DefaultObjectTransformer )
501+ ]
502+ return (
503+ len (default_transf ) and class_name in default_transf [0 ]._type_mapper
504+ )
499505
500506 def _read_class_data (self , instance ):
501507 # type: (JavaInstance) -> None
@@ -512,11 +518,22 @@ def _read_class_data(self, instance):
512518 for cd in classes :
513519 values = {} # type: Dict[JavaField, Any]
514520 cd .validate ()
515- if cd .data_type == ClassDataType .NOWRCLASS or cd .data_type == ClassDataType .WRCLASS :
516- read_custom_data = cd .data_type == ClassDataType .WRCLASS and cd .is_super_class and not self ._is_default_supported (cd .name )
517- if read_custom_data or cd .data_type == ClassDataType .WRCLASS and instance .is_external_instance :
521+ if (
522+ cd .data_type == ClassDataType .NOWRCLASS
523+ or cd .data_type == ClassDataType .WRCLASS
524+ ):
525+ read_custom_data = (
526+ cd .data_type == ClassDataType .WRCLASS
527+ and cd .is_super_class
528+ and not self ._is_default_supported (cd .name )
529+ )
530+ if (
531+ read_custom_data
532+ or cd .data_type == ClassDataType .WRCLASS
533+ and instance .is_external_instance
534+ ):
518535 annotations [cd ] = self ._read_class_annotations (cd )
519- else :
536+ else :
520537 for field in cd .fields :
521538 values [field ] = self ._read_field_value (field .type )
522539 all_data [cd ] = values
@@ -568,7 +585,9 @@ def _read_field_value(self, field_type):
568585 if sub_type_code == TerminalCode .TC_REFERENCE :
569586 return self ._do_classdesc (sub_type_code )
570587 elif sub_type_code != TerminalCode .TC_ARRAY :
571- raise ValueError ("Array type listed, but type code != TC_ARRAY" )
588+ raise ValueError (
589+ "Array type listed, but type code != TC_ARRAY"
590+ )
572591
573592 content = self ._read_content (sub_type_code , False )
574593 if content is not None and content .is_exception :
0 commit comments