From 9ea66bf97bc0d9af8e7cb4c41b8fc302a3472321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DAVID?= Date: Thu, 13 Jun 2024 16:06:03 +0200 Subject: [PATCH] fix ruff reported issues --- classRepresentation/methodGiws.py | 8 ++++---- classRepresentation/objectGiws.py | 22 +++++++++------------ datatypes/booleanDataGiws.py | 4 ++-- datatypes/dataBufferGiws.py | 4 ++-- datatypes/dataFactoryGiws.py | 33 +++++++++++++++---------------- datatypes/dataGiws.py | 6 +++--- datatypes/stringDataGiws.py | 4 ++-- 7 files changed, 38 insertions(+), 43 deletions(-) diff --git a/classRepresentation/methodGiws.py b/classRepresentation/methodGiws.py index fa5d59d..5bde0de 100644 --- a/classRepresentation/methodGiws.py +++ b/classRepresentation/methodGiws.py @@ -92,7 +92,7 @@ def getParametersCXX(self): # In the case where there is no input argument # but return an array of int (or an other type) # needed to lenRow - if self.getReturn().isArray() and configGiws().getDisableReturnSize() != True: + if self.getReturn().isArray() and not configGiws().getDisableReturnSize(): str += ", " else: @@ -121,7 +121,7 @@ def __createMethodBody(self): str += """ jclass stringArrayClass = curEnv->FindClass("java/lang/String");""" arrayOfStringDeclared = True - if paramType.specificPreProcessing(parameter, self.getDetachThread()) != None: + if paramType.specificPreProcessing(parameter, self.getDetachThread()) is not None: str += paramType.specificPreProcessing( parameter, self.getDetachThread()) @@ -188,7 +188,7 @@ def generateCXXHeader(self): static = "" ret = "" - if self.getReturn().isArray() and configGiws().getDisableReturnSize() != True: + if self.getReturn().isArray() and not configGiws().getDisableReturnSize(): if len(self.__parameters) != 0: ret += ", " if self.getReturn().getDimensionArray() == 1: @@ -206,7 +206,7 @@ def generateCXXBody(self, className): self.getReturn().getNativeType(), className, self.getName()) ret = "" - if self.getReturn().isArray() and configGiws().getDisableReturnSize() != True: + if self.getReturn().isArray() and not configGiws().getDisableReturnSize(): if len(self.__parameters) != 0: ret += ", " if self.getReturn().getDimensionArray() == 1: diff --git a/classRepresentation/objectGiws.py b/classRepresentation/objectGiws.py index f815ac1..b6e07cc 100644 --- a/classRepresentation/objectGiws.py +++ b/classRepresentation/objectGiws.py @@ -47,10 +47,6 @@ class objectGiws: # Which class it extends __extends = None - def __init__(self, name): - self.__name = name - self.__methods = [] - def __init__(self, name, extends): self.__name = name self.__methods = [] @@ -78,7 +74,7 @@ def __getDeclarationOfCachingMethodID(self): for param in method.getParameters(): # Avoids to load the class String each time we need it - if isinstance(param.getType(), stringDataGiws) and param.getType().isArray() == True and stringClassSet != True and method.getModifier() != "static": + if isinstance(param.getType(), stringDataGiws) and param.getType().isArray() and not stringClassSet and method.getModifier() != "static": str += """ jclass localStringArrayClass = curEnv->FindClass("java/lang/String"); stringArrayClass = static_cast(curEnv->NewGlobalRef(localStringArrayClass)); @@ -86,7 +82,7 @@ def __getDeclarationOfCachingMethodID(self): """ stringClassSet = True - if self.getExtendedClass() != None: + if self.getExtendedClass() is not None: # Get the father object to work on it. str += self.getExtendedClass().__getDeclarationOfCachingMethodID() @@ -145,7 +141,7 @@ def __getConstructorWhichInstanciateTheNewObject(self): strMethodID = self.__getDeclarationOfCachingMethodID() constructorProfile = """%s::%s""" % ( self.getName(), self.__getConstructorProfileWhichInstanciateTheNewObject()) - if self.getExtendedClass() != None: + if self.getExtendedClass() is not None: constructorProfile += """ : %s(fakeGiwsDataType::fakeGiwsDataType())""" % ( self.getExtendedClass().getName()) @@ -225,7 +221,7 @@ def __getConstructorWhichUsesAnAlreadyExistingJObject(self): exit(EXIT_FAILURE);""" constructorProfile = """%s::%s""" % ( self.getName(), self.__getConstructorProfileWhichUsesAnAlreadyExistingJObject()) - if self.getExtendedClass() != None: + if self.getExtendedClass() is not None: constructorProfile += """ : %s(fakeGiwsDataType::fakeGiwsDataType()) """ % ( self.getExtendedClass().getName()) return """ @@ -280,7 +276,7 @@ def getConstructorWhichInstanciateTheNewObjectHeaderCXX(self): def __getFakeConstructorForExtendedClasses(self): str = "" - if self.getExtendedClass() == None: + if self.getExtendedClass() is None: # It is a potential master class, add the fake constructor str += """ /** @@ -302,7 +298,7 @@ def getMethodsProfileForMethodIdCache(self): """ % method.getUniqueNameOfTheMethod() for param in method.getParameters(): # Avoids to load the class String each time we need it - if isinstance(param.getType(), stringDataGiws) and param.getType().isArray() == True and stringClassSet != True: + if isinstance(param.getType(), stringDataGiws) and param.getType().isArray() and not stringClassSet: str += """jclass stringArrayClass; """ stringClassSet = True @@ -311,7 +307,7 @@ def getMethodsProfileForMethodIdCache(self): def getProtectedFields(self): str = "" - if self.getExtendedClass() == None: + if self.getExtendedClass() is None: str += """ jobject instance; jclass instanceClass; // cache class @@ -336,7 +332,7 @@ def getMethodsCXX(self, type="header"): def generateCXXHeader(self, packageName): JNIObjectName = packageName + "/" + self.getName() - if self.getExtendedClass() == None: + if self.getExtendedClass() is None: classProfile = """class GIWSEXPORT %s {""" % (self.getName()) else: classProfile = """class GIWSEXPORT %s : public %s { @@ -460,7 +456,7 @@ def needCaching(self): for method in self.__methods: for param in method.getParameters(): - if param.getType().isByteBufferBased() == True: + if param.getType().isByteBufferBased(): return True return False diff --git a/datatypes/booleanDataGiws.py b/datatypes/booleanDataGiws.py index ad5719e..aa055bb 100644 --- a/datatypes/booleanDataGiws.py +++ b/datatypes/booleanDataGiws.py @@ -86,7 +86,7 @@ def specificPostProcessing(self, detachThread): if self.isArray(): str = JNIFrameWork().getExceptionCheckProfile(detachThread) strCommon = "" - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): strCommon += "int *lenRow;" strCommon += """ *lenRow = curEnv->GetArrayLength(res); @@ -109,7 +109,7 @@ def specificPostProcessing(self, detachThread): curEnv->DeleteLocalRef(res); """ else: - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): str += "int *lenCol;" return str + strCommon + """ bool ** myArray = new bool*[*lenRow]; diff --git a/datatypes/dataBufferGiws.py b/datatypes/dataBufferGiws.py index 00dc9b8..8b2f272 100644 --- a/datatypes/dataBufferGiws.py +++ b/datatypes/dataBufferGiws.py @@ -155,7 +155,7 @@ def specificPostProcessing(self, detachThread): if self.isArray(): strCommon = "" strDeclaration = "" - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): strCommon += "int lenRow;" else: # The size of the array is returned as output argument of the @@ -175,7 +175,7 @@ def specificPostProcessing(self, detachThread): """ % (self.getNativeType(), self.temporaryVariableName, self.getNativeType()) return str else: - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): str += "int lenCol;" str += strCommon + """ TODO voir si on delete ca diff --git a/datatypes/dataFactoryGiws.py b/datatypes/dataFactoryGiws.py index c5b4901..0e8c179 100644 --- a/datatypes/dataFactoryGiws.py +++ b/datatypes/dataFactoryGiws.py @@ -61,23 +61,22 @@ def __init__(self): self.dict = { "int": intDataGiws, - "char": charDataGiws, - "long": longDataGiws, - "double": doubleDataGiws, - "boolean": booleanDataGiws, - "byte": byteDataGiws, - "float": floatDataGiws, - "short": shortDataGiws, - "String": stringDataGiws, - "void": voidDataGiws, - "DoubleBuffer": DoubleBufferDataGiws, - "ByteBuffer": ByteBufferDataGiws, - "CharBuffer": CharBufferDataGiws, - "DoubleBuffer": DoubleBufferDataGiws, - "FloatBuffer": FloatBufferDataGiws, - "IntBuffer": IntBufferDataGiws, - "LongBuffer": LongBufferDataGiws, - "ShortBuffer": ShortBufferDataGiws + "char": charDataGiws, + "long": longDataGiws, + "double": doubleDataGiws, + "boolean": booleanDataGiws, + "byte": byteDataGiws, + "float": floatDataGiws, + "short": shortDataGiws, + "String": stringDataGiws, + "void": voidDataGiws, + "DoubleBuffer": DoubleBufferDataGiws, + "ByteBuffer": ByteBufferDataGiws, + "CharBuffer": CharBufferDataGiws, + "FloatBuffer": FloatBufferDataGiws, + "IntBuffer": IntBufferDataGiws, + "LongBuffer": LongBufferDataGiws, + "ShortBuffer": ShortBufferDataGiws } def create(self, dataTypeToCreate): diff --git a/datatypes/dataGiws.py b/datatypes/dataGiws.py index 16759d1..c3dabd0 100644 --- a/datatypes/dataGiws.py +++ b/datatypes/dataGiws.py @@ -40,7 +40,7 @@ def abstractMethod(obj=None): """ Use this instead of 'pass' for the body of abstract methods. """ - raise Exception("Unimplemented abstract method: %s" % _functionId(obj, 1)) + raise Exception("Unimplemented abstract method") # # This class intend to create a generic object for datatype @@ -237,7 +237,7 @@ def specificPostProcessing(self, detachThread): str += JNIFrameWork().getExceptionCheckProfile(detachThread) strCommon = "" strDeclaration = "" - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): strCommon += "int lenRow;" else: # The size of the array is returned as output argument of the @@ -263,7 +263,7 @@ def specificPostProcessing(self, detachThread): return str else: - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): str += "int lenCol;" str += strCommon + """ %s ** myArray = new %s*[%s lenRow]; diff --git a/datatypes/stringDataGiws.py b/datatypes/stringDataGiws.py index 6ea5109..487cf1b 100644 --- a/datatypes/stringDataGiws.py +++ b/datatypes/stringDataGiws.py @@ -183,7 +183,7 @@ def specificPostProcessing(self, detachThread): if self.isArray(): strCommon = "" strDeclaration = "" - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): strCommon += "int lenRow;" else: # The size of the array is returned as output argument of the @@ -209,7 +209,7 @@ def specificPostProcessing(self, detachThread): """ % (strDeclaration, strDeclaration) return str else: - if configGiws().getDisableReturnSize() == True: + if configGiws().getDisableReturnSize(): str += "int lenCol;" str += strCommon + """ char ***arrayOfString;