Skip to content

Commit

Permalink
fix ruff reported issues
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcl committed Jun 13, 2024
1 parent a8720c7 commit 9ea66bf
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 43 deletions.
8 changes: 4 additions & 4 deletions classRepresentation/methodGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
22 changes: 9 additions & 13 deletions classRepresentation/objectGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -78,15 +74,15 @@ 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<jclass>(curEnv->NewGlobalRef(localStringArrayClass));
curEnv->DeleteLocalRef(localStringArrayClass);
"""
stringClassSet = True

if self.getExtendedClass() != None:
if self.getExtendedClass() is not None:
# Get the father object to work on it.
str += self.getExtendedClass().__getDeclarationOfCachingMethodID()

Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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 """
Expand Down Expand Up @@ -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 += """
/**
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions datatypes/booleanDataGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions datatypes/dataBufferGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
33 changes: 16 additions & 17 deletions datatypes/dataFactoryGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions datatypes/dataGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions datatypes/stringDataGiws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 9ea66bf

Please sign in to comment.