3939import logging
4040import os
4141import struct
42- import sys
4342
4443try :
4544 # Python 2
@@ -1663,6 +1662,7 @@ def _convert_type_to_char(self, type_char):
16631662
16641663# ------------------------------------------------------------------------------
16651664
1665+
16661666def read (data , fmt_str ):
16671667 """
16681668 Reads input bytes and extract the given structure. Returns both the read
@@ -1677,16 +1677,16 @@ def read(data, fmt_str):
16771677
16781678
16791679def read_string (data , length_fmt = "H" ):
1680- """
1681- Reads a serialized string
1680+ """
1681+ Reads a serialized string
16821682
1683- :param data: Bytes where to read the string from
1684- :param length_fmt: Structure format of the string length (H or Q)
1685- :return: The deserialized string
1686- """
1687- (length ,), data = read (data , ">{0}" .format (length_fmt ))
1688- ba , data = data [:length ], data [length :]
1689- return to_unicode (ba ), data
1683+ :param data: Bytes where to read the string from
1684+ :param length_fmt: Structure format of the string length (H or Q)
1685+ :return: The deserialized string
1686+ """
1687+ (length ,), data = read (data , ">{0}" .format (length_fmt ))
1688+ ba , data = data [:length ], data [length :]
1689+ return to_unicode (ba ), data
16901690
16911691
16921692class DefaultObjectTransformer (object ):
@@ -1718,6 +1718,7 @@ class JavaPrimitiveClass(JavaObject):
17181718 """
17191719 Parent of Java classes matching a primitive (Bool, Integer, Long, ...)
17201720 """
1721+
17211722 def __init__ (self , unmarshaller ):
17221723 JavaObject .__init__ (self )
17231724 self .value = None
@@ -1729,7 +1730,7 @@ def __repr__(self):
17291730 return repr (self .value )
17301731
17311732 def __hash__ (self ):
1732- return hash (self .value )
1733+ return hash (self .value )
17331734
17341735 def __eq__ (self , other ):
17351736 return self .value == other
@@ -1827,6 +1828,7 @@ class JavaTime(JavaObject):
18271828 The semantic of the fields depends on the type of time that has been
18281829 parsed
18291830 """
1831+
18301832 DURATION_TYPE = 1
18311833 INSTANT_TYPE = 2
18321834 LOCAL_DATE_TYPE = 3
@@ -1905,27 +1907,27 @@ def do_instant(self, unmarshaller, data):
19051907 return data
19061908
19071909 def do_local_date (self , unmarshaller , data ):
1908- (self .year , self .month , self .day ), data = read (data , ' >ibb' )
1910+ (self .year , self .month , self .day ), data = read (data , " >ibb" )
19091911 return data
19101912
19111913 def do_local_time (self , unmarshaller , data ):
1912- (hour ,), data = read (data , '>b' )
1914+ (hour ,), data = read (data , ">b" )
19131915 minute = 0
19141916 second = 0
19151917 nano = 0
19161918
19171919 if hour < 0 :
19181920 hour = ~ hour
19191921 else :
1920- (minute ,), data = read (data , '>b' )
1922+ (minute ,), data = read (data , ">b" )
19211923 if minute < 0 :
19221924 minute = ~ minute
19231925 else :
1924- (second ,), data = read (data , '>b' )
1926+ (second ,), data = read (data , ">b" )
19251927 if second < 0 :
19261928 second = ~ second
19271929 else :
1928- (nano ,), data = read (data , '>i' )
1930+ (nano ,), data = read (data , ">i" )
19291931
19301932 self .hour = hour
19311933 self .minute = minute
0 commit comments