[Mod] flake8 code quality improvement

This commit is contained in:
vn.py 2019-09-03 10:20:36 +08:00
parent 65e71ae66d
commit 3aab7b13db
9 changed files with 30 additions and 23 deletions

View File

@ -730,4 +730,3 @@ CFutureRspStrategyDetailField = {
"SafeDeep": "int", "SafeDeep": "int",
"MainRange": "int", "MainRange": "int",
} }

View File

@ -117,4 +117,3 @@ CMarketRspTradeDateField = {
"TradeDate": "string", "TradeDate": "string",
"TradeProduct": "string", "TradeProduct": "string",
} }

View File

@ -607,4 +607,3 @@ CStockReqVerifyCodeField = {
"VerifyCode": "string", "VerifyCode": "string",
"ErrorDescription": "string", "ErrorDescription": "string",
} }

View File

@ -130,7 +130,8 @@ class ApiGenerator:
line = self.lines[name] line = self.lines[name]
on_name = name.replace("On", "on") on_name = name.replace("On", "on")
f.write(line.replace("virtual void ", f"void {self.class_name}::") + "\n") f.write(line.replace("virtual void ",
f"void {self.class_name}::") + "\n")
f.write("{\n") f.write("{\n")
f.write("\tgil_scoped_acquire acquire;\n") f.write("\tgil_scoped_acquire acquire;\n")
@ -153,9 +154,11 @@ class ApiGenerator:
struct_fields = self.structs[type_] struct_fields = self.structs[type_]
for struct_field, struct_type in struct_fields.items(): for struct_field, struct_type in struct_fields.items():
if struct_type == "string": if struct_type == "string":
f.write(f"\t\terror[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") f.write(
f"\t\terror[\"{struct_field}\"] = toUtf({field}->{struct_field});\n")
else: else:
f.write(f"\t\terror[\"{struct_field}\"] = {field}->{struct_field};\n") f.write(
f"\t\terror[\"{struct_field}\"] = {field}->{struct_field};\n")
f.write("\t}\n") f.write("\t}\n")
else: else:
@ -168,9 +171,11 @@ class ApiGenerator:
struct_fields = self.structs[type_] struct_fields = self.structs[type_]
for struct_field, struct_type in struct_fields.items(): for struct_field, struct_type in struct_fields.items():
if struct_type == "string": if struct_type == "string":
f.write(f"\t\tdata[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") f.write(
f"\t\tdata[\"{struct_field}\"] = toUtf({field}->{struct_field});\n")
else: else:
f.write(f"\t\tdata[\"{struct_field}\"] = {field}->{struct_field};\n") f.write(
f"\t\tdata[\"{struct_field}\"] = {field}->{struct_field};\n")
f.write("\t}\n") f.write("\t}\n")
@ -260,11 +265,14 @@ class ApiGenerator:
if __name__ == "__main__": if __name__ == "__main__":
market_generator = ApiGenerator("../include/da/DAMarketApi.h", "da", "market", "MarketApi") market_generator = ApiGenerator(
"../include/da/DAMarketApi.h", "da", "market", "MarketApi")
market_generator.run() market_generator.run()
future_generator = ApiGenerator("../include/da/DAFutureApi.h", "da", "future", "FutureApi") future_generator = ApiGenerator(
"../include/da/DAFutureApi.h", "da", "future", "FutureApi")
future_generator.run() future_generator.run()
stock_generator = ApiGenerator("../include/da/DAStockApi.h", "da", "stock", "StockApi") stock_generator = ApiGenerator(
"../include/da/DAStockApi.h", "da", "stock", "StockApi")
stock_generator.run() stock_generator.run()

View File

@ -91,11 +91,14 @@ class StructGenerator:
if __name__ == "__main__": if __name__ == "__main__":
generator_future = StructGenerator("../include/da/DAFutureStruct.h", "da", "future") generator_future = StructGenerator(
"../include/da/DAFutureStruct.h", "da", "future")
generator_future.run() generator_future.run()
generator_stock = StructGenerator("../include/da/DAStockStruct.h", "da", "stock") generator_stock = StructGenerator(
"../include/da/DAStockStruct.h", "da", "stock")
generator_stock.run() generator_stock.run()
generator_market = StructGenerator("../include/da/DAMarketStruct.h", "da", "market") generator_market = StructGenerator(
"../include/da/DAMarketStruct.h", "da", "market")
generator_market.run() generator_market.run()

View File

@ -4909,4 +4909,3 @@ CThostFtdcDepartmentUserField = {
CThostFtdcQueryFreqField = { CThostFtdcQueryFreqField = {
"QueryFreq": "int", "QueryFreq": "int",
} }