Skip to content

Commit 86a678a

Browse files
committed
Fixed warnings lgtm
1 parent ba9d822 commit 86a678a

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

example-of-exported/py3/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# SomeClient Python Library
22

33
Automatically generated by wsjcpp-jsonrpc20.
4-
* Version: v0.0.2
5-
* Date: Thu, 17 Sep 2020 05:41:35 GMT
4+
* Version: v0.0.3
5+
* Date: Fri, 18 Sep 2020 03:27:31 GMT
66

77
Example connect/disconnect:
88
```

example-of-exported/py3/libwsjcppjson20client/SomeClient.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
### This file was automatically generated by wsjcpp-jsonrpc20
4-
### Version: v0.0.2
5-
### Date: Thu, 17 Sep 2020 05:41:35 GMT
4+
### Version: v0.0.3
5+
### Date: Fri, 18 Sep 2020 03:27:31 GMT
66

77
import asyncio
88
import websocket
@@ -13,7 +13,7 @@
1313
class SomeClient:
1414
__ws = None
1515
__url = None
16-
__cli_version = 'v0.0.2'
16+
__cli_version = 'v0.0.3'
1717
__loop = None
1818
__token = None
1919
__connecting = False
@@ -45,7 +45,7 @@ def hasConnection(self):
4545
def getToken(self):
4646
return self.__token
4747
def setToken(self, token):
48-
if self.__token == None:
48+
if self.__token is None:
4949
self.__token = token
5050
else:
5151
print('ERROR: Token can be set only once')
@@ -56,10 +56,10 @@ def close(self):
5656
self.__ws = None
5757

5858
def receiveIncomingMesssages(self):
59-
if self.__ws == None:
59+
if self.__ws is None:
6060
return None # TODO has not connection
6161
while True:
62-
if self.__ws == None:
62+
if self.__ws is None:
6363
return None # TODO has not connection
6464
ready = select.select([self.__ws], [], [], 1)
6565
if ready[0]:
@@ -83,7 +83,7 @@ async def __looper(self, messageId):
8383
max_time = 5*10 # 5 seconds
8484
counter_time = 0
8585
while True:
86-
if self.__ws == None:
86+
if self.__ws is None:
8787
return None # TODO has not connection
8888
for inmsg in self.__incomingMesssages:
8989
if inmsg['id'] == messageId:
@@ -130,7 +130,7 @@ def __sendCommand(self, req):
130130
return result
131131

132132
def preprocessIncomeJson(self, jsonIn):
133-
if jsonIn == None:
133+
if jsonIn is None:
134134
return jsonIn
135135
if jsonIn['method'] == 'auth_logoff' and 'result' in jsonIn:
136136
self.__token = None
@@ -157,12 +157,12 @@ def auth_login(self, login, password, client_app_name = None, client_app_version
157157
"""
158158
if not self.hasConnection(): return None
159159
reqJson = self.generateBaseCommand('auth_login')
160-
if login == None:
160+
if login is None:
161161
raise Exception('Parameter "login" expected (lib: SomeClient.auth_login)')
162162
if not isinstance(login, str):
163163
raise Exception('Parameter "login" expected datatype "str" (lib: SomeClient.auth_login )')
164164
reqJson['params']['login'] = login
165-
if password == None:
165+
if password is None:
166166
raise Exception('Parameter "password" expected (lib: SomeClient.auth_login)')
167167
if not isinstance(password, str):
168168
raise Exception('Parameter "password" expected datatype "str" (lib: SomeClient.auth_login )')
@@ -207,7 +207,7 @@ def auth_token(self, token, client_app_name = None, client_app_version = None):
207207
"""
208208
if not self.hasConnection(): return None
209209
reqJson = self.generateBaseCommand('auth_token')
210-
if token == None:
210+
if token is None:
211211
raise Exception('Parameter "token" expected (lib: SomeClient.auth_token)')
212212
if not isinstance(token, str):
213213
raise Exception('Parameter "token" expected datatype "str" (lib: SomeClient.auth_token )')
@@ -242,7 +242,7 @@ def game_create(self, uuid, cost, public, name = None, age = None, activated = N
242242
"""
243243
if not self.hasConnection(): return None
244244
reqJson = self.generateBaseCommand('game_create')
245-
if uuid == None:
245+
if uuid is None:
246246
raise Exception('Parameter "uuid" expected (lib: SomeClient.game_create)')
247247
if not isinstance(uuid, str):
248248
raise Exception('Parameter "uuid" expected datatype "str" (lib: SomeClient.game_create )')
@@ -251,7 +251,7 @@ def game_create(self, uuid, cost, public, name = None, age = None, activated = N
251251
if not isinstance(name, str):
252252
raise Exception('Parameter "name" expected datatype "str" (lib: SomeClient.game_create )')
253253
reqJson['params']['name'] = name
254-
if cost == None:
254+
if cost is None:
255255
raise Exception('Parameter "cost" expected (lib: SomeClient.game_create)')
256256
if not isinstance(cost, int):
257257
raise Exception('Parameter "cost" expected datatype "int" (lib: SomeClient.game_create )')
@@ -260,7 +260,7 @@ def game_create(self, uuid, cost, public, name = None, age = None, activated = N
260260
if not isinstance(age, int):
261261
raise Exception('Parameter "age" expected datatype "int" (lib: SomeClient.game_create )')
262262
reqJson['params']['age'] = age
263-
if public == None:
263+
if public is None:
264264
raise Exception('Parameter "public" expected (lib: SomeClient.game_create)')
265265
if not isinstance(public, bool):
266266
raise Exception('Parameter "public" expected datatype "bool" (lib: SomeClient.game_create )')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .SomeClient import *
1+
from .SomeClient import SomeClient

example-of-exported/py3/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='libwsjcppjson20client',
8-
version='v0.0.2',
8+
version='v0.0.3',
99
packages=['libwsjcppjson20client'],
1010
install_requires=['websocket-client>=0.56.0', 'requests>=2.21.0'],
1111
keywords=['wsjcpp-jsonrpc20', 'wsjcpp', 'wsjcpp-jsonrpc20', 'example-python-client'],

src/wsjcpp_jsonrpc20_export_cli_python.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class PyCodeLine{
3434

3535
~PyCodeLine() {
3636
if (m_pParent == NULL) {
37-
std::cout << "destruct root \n";
37+
// std::cout << "destruct root \n";
3838
} else {
39-
std::cout << "destruct something else [" << m_sLine << "]\n";
39+
// std::cout << "destruct something else [" << m_sLine << "]\n";
4040
}
4141
}
4242

@@ -86,6 +86,7 @@ class PyCodeBuilder {
8686

8787
~PyCodeBuilder() {
8888
// std::cout << "destruct something else [" << m_pCurr->getLine() << "]\n";
89+
delete m_pCurr;
8990
}
9091

9192
PyCodeBuilder &add(const std::string &sLine) {
@@ -429,7 +430,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportInitPy() {
429430
WsjcppLog::info(TAG, "Prepare __init__.py " + sFilename);
430431
std::ofstream __init__;
431432
__init__.open (sFilename);
432-
__init__ << "from ." << m_sClassName << " import *\n";
433+
__init__ << "from ." << m_sClassName << " import " << m_sClassName << "\n";
433434
WsjcppLog::ok(TAG, "Done: " + sFilename);
434435
return true;
435436
}
@@ -534,7 +535,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
534535
.add("return self.__token")
535536
.end()
536537
.sub("def setToken(self, token):")
537-
.sub("if self.__token == None:")
538+
.sub("if self.__token is None:")
538539
.add("self.__token = token")
539540
.end()
540541
.sub("else:")
@@ -551,11 +552,11 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
551552
.end()
552553
.add("")
553554
.sub("def receiveIncomingMesssages(self):")
554-
.sub("if self.__ws == None:")
555+
.sub("if self.__ws is None:")
555556
.add("return None # TODO has not connection")
556557
.end()
557558
.sub("while True:")
558-
.sub("if self.__ws == None:")
559+
.sub("if self.__ws is None:")
559560
.add("return None # TODO has not connection")
560561
.end()
561562
.add("ready = select.select([self.__ws], [], [], 1)")
@@ -586,7 +587,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
586587
.add("max_time = 5*10 # 5 seconds")
587588
.add("counter_time = 0")
588589
.sub("while True:")
589-
.sub("if self.__ws == None:")
590+
.sub("if self.__ws is None:")
590591
.add("return None # TODO has not connection")
591592
.end()
592593
.sub("for inmsg in self.__incomingMesssages:")
@@ -651,7 +652,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
651652
// prepare login / logoff
652653
builder
653654
.sub("def preprocessIncomeJson(self, jsonIn):")
654-
.sub("if jsonIn == None:")
655+
.sub("if jsonIn is None:")
655656
.add("return jsonIn")
656657
.end()
657658
;
@@ -746,7 +747,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
746747
std::string sParamName = paramDef.getName();
747748
if (paramDef.isRequired()) {
748749
builder
749-
.sub("if " + sParamName + " == None: ")
750+
.sub("if " + sParamName + " is None: ")
750751
.add("raise Exception('Parameter \"" + sParamName + "\" expected (lib: " + m_sClassName + "." + sMethod + ")')")
751752
.end();
752753
exportCliPythonAddCheckDataTypeOfParam(builder, paramDef, m_sClassName, sMethod);

0 commit comments

Comments
 (0)