@@ -128,32 +128,11 @@ WsjcppJsonRpc20ExportCliPython::WsjcppJsonRpc20ExportCliPython(
128
128
const std::string &sPackageName
129
129
) : WsjcppJsonRpc20ExportCliBase(sExportDir , sPackageName ) {
130
130
TAG = " WsjcppJsonRpc20ExportCliPython" ;
131
- m_sAuthorName = " Unknown" ;
132
- m_sAuthorEmail = " unknown" ;
133
- m_sClassName = " Unknown" ;
134
131
m_sUrl = " none" ;
135
132
}
136
133
137
134
// ---------------------------------------------------------------------
138
135
139
- void WsjcppJsonRpc20ExportCliPython::setAuthorName (const std::string &sAuthorName ) {
140
- m_sAuthorName = sAuthorName ;
141
- }
142
-
143
- // ---------------------------------------------------------------------
144
-
145
- void WsjcppJsonRpc20ExportCliPython::setAuthorEmail (const std::string &sAuthorEmail ) {
146
- m_sAuthorEmail = sAuthorEmail ;
147
- }
148
-
149
- // ---------------------------------------------------------------------
150
-
151
- void WsjcppJsonRpc20ExportCliPython::setClassName (const std::string &sClassName ) {
152
- m_sClassName = sClassName ;
153
- }
154
-
155
- // ---------------------------------------------------------------------
156
-
157
136
void WsjcppJsonRpc20ExportCliPython::setUrl (const std::string &sUrl ) {
158
137
m_sUrl = sUrl ;
159
138
}
@@ -252,7 +231,7 @@ bool WsjcppJsonRpc20ExportCliPython::prepareReadmeMdIfNeed() {
252
231
if (!WsjcppCore::fileExists (sReadmeMd )) {
253
232
std::string sContentReadme =
254
233
" #" + this ->getPackageName () + " \n\n "
255
- + m_sClassName + " Python Library for " + this ->getAppName () + " \n\n "
234
+ + this -> getClassName () + " Python Library for " + this ->getAppName () + " \n\n "
256
235
+ " ## Install \n\n "
257
236
+ " ```\n "
258
237
+ " $ pip3 install " + this ->getPackageName () + " --upgrade\n "
@@ -261,8 +240,8 @@ bool WsjcppJsonRpc20ExportCliPython::prepareReadmeMdIfNeed() {
261
240
+ " ```\n "
262
241
+ " #!/usr/bin/env python3\n "
263
242
+ " # -*- coding: utf-8 -*-\n "
264
- + " from " + this ->getPackageName () + " import " + m_sClassName + " \n\n "
265
- + " client = " + m_sClassName + " (\" ws://host/ws-api/\" )\n\n "
243
+ + " from " + this ->getPackageName () + " import " + this -> getClassName () + " \n\n "
244
+ + " client = " + this -> getClassName () + " (\" ws://host/ws-api/\" )\n\n "
266
245
+ " resp = client.server_api({})\n\n "
267
246
+ " print(resp)\n "
268
247
+ " ```\n\n "
@@ -293,9 +272,9 @@ bool WsjcppJsonRpc20ExportCliPython::exportSetupPy() {
293
272
" packages=['" + this ->getPackageName () + " '],\n "
294
273
" install_requires=['websocket-client>=0.56.0', 'requests>=2.21.0'],\n "
295
274
" keywords=['" + WsjcppCore::join (m_vKeywords, " ', '" ) + " '],\n "
296
- " author='" + m_sAuthorName + " ',\n "
297
- " author_email='" + m_sAuthorEmail + " ',\n "
298
- " description='" + m_sClassName + " Python Library for " + this ->getAppName () + " ',\n "
275
+ " author='" + this -> getAuthorName () + " ',\n "
276
+ " author_email='" + this -> getAuthorEmail () + " ',\n "
277
+ " description='" + this -> getClassName () + " Python Library for " + this ->getAppName () + " ',\n "
299
278
" long_description=long_description,\n "
300
279
" long_description_content_type='text/markdown',\n "
301
280
" url='" + m_sUrl + " ',\n "
@@ -333,14 +312,14 @@ bool WsjcppJsonRpc20ExportCliPython::exportAPImd() {
333
312
334
313
long nSec = WsjcppCore::getCurrentTimeInSeconds ();
335
314
336
- apimd << " # " + m_sClassName + " Python Library \n\n " ;
315
+ apimd << " # " + this -> getClassName () + " Python Library \n\n " ;
337
316
apimd << " Automatically generated by " << this ->getAppName () << " . \n " ;
338
317
apimd << " * Version: " << this ->getAppVersion () << " \n " ;
339
318
apimd << " * Date: " << WsjcppCore::formatTimeForWeb (nSec) << " \n\n " ;
340
319
apimd << " Example connect/disconnect:\n "
341
320
<< " ```\n "
342
- << " from " + getPackageName () + " import " + m_sClassName + " \n\n "
343
- << " client = " + m_sClassName + " ('ws://host:1234')\n "
321
+ << " from " + getPackageName () + " import " + this -> getClassName () + " \n\n "
322
+ << " client = " + this -> getClassName () + " ('ws://host:1234')\n "
344
323
<< " ... \n "
345
324
<< " client.close()\n "
346
325
<< " ```\n " ;
@@ -411,7 +390,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportInitPy() {
411
390
WsjcppLog::info (TAG, " Prepare __init__.py " + sFilename );
412
391
std::ofstream __init__;
413
392
__init__.open (sFilename );
414
- __init__ << " from ." << m_sClassName << " import " << m_sClassName << " \n " ;
393
+ __init__ << " from ." << this -> getClassName () << " import " << this -> getClassName () << " \n " ;
415
394
WsjcppLog::ok (TAG, " Done: " + sFilename );
416
395
return true ;
417
396
}
@@ -454,8 +433,8 @@ void exportCliPythonAddCheckDataTypeOfParam(
454
433
// ---------------------------------------------------------------------
455
434
456
435
bool WsjcppJsonRpc20ExportCliPython::exportClientPy () {
457
- std::string sFilename = this ->getExportDir () + " /" + this ->getPackageName () + " /" + m_sClassName + " .py" ;
458
- WsjcppLog::info (TAG, " Prepare " + m_sClassName + " .py: " + sFilename );
436
+ std::string sFilename = this ->getExportDir () + " /" + this ->getPackageName () + " /" + this -> getClassName () + " .py" ;
437
+ WsjcppLog::info (TAG, " Prepare " + this -> getClassName () + " .py: " + sFilename );
459
438
460
439
std::ofstream clientpy;
461
440
clientpy.open (sFilename );
@@ -476,7 +455,7 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
476
455
.add (" import select" )
477
456
.add (" import time" )
478
457
.add (" " )
479
- .sub (" class " + m_sClassName + " :" )
458
+ .sub (" class " + this -> getClassName () + " :" )
480
459
.add (" __ws = None" )
481
460
.add (" __url = None" )
482
461
.add (" __cli_version = '" + this ->getAppVersion () + " '" )
@@ -732,14 +711,14 @@ bool WsjcppJsonRpc20ExportCliPython::exportClientPy() {
732
711
if (paramDef.isRequired ()) {
733
712
builder
734
713
.sub (" if " + sParamName + " is None: " )
735
- .add (" raise Exception('Parameter \" " + sParamName + " \" expected (lib: " + m_sClassName + " ." + sMethod + " )')" )
714
+ .add (" raise Exception('Parameter \" " + sParamName + " \" expected (lib: " + this -> getClassName () + " ." + sMethod + " )')" )
736
715
.end ();
737
- exportCliPythonAddCheckDataTypeOfParam (builder, paramDef, m_sClassName , sMethod );
716
+ exportCliPythonAddCheckDataTypeOfParam (builder, paramDef, this -> getClassName () , sMethod );
738
717
builder.add (" reqJson['params']['" + sParamName + " '] = " + sParamName );
739
718
} else if (paramDef.isOptional ()) {
740
719
builder
741
720
.sub (" if " + sParamName + " != None: " );
742
- exportCliPythonAddCheckDataTypeOfParam (builder, paramDef, m_sClassName , sMethod );
721
+ exportCliPythonAddCheckDataTypeOfParam (builder, paramDef, this -> getClassName () , sMethod );
743
722
builder
744
723
.add (" reqJson['params']['" + sParamName + " '] = " + sParamName )
745
724
.end ();
0 commit comments