Skip to content

Commit

Permalink
[Mod] flake8代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy committed Aug 1, 2022
1 parent 927ce86 commit 2ab213b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ def get_ext_modules() -> list:

return [vnosttd, vnostmd]


setup(ext_modules=get_ext_modules())
14 changes: 7 additions & 7 deletions vnpy_ost/api/generator/generate_api_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,24 @@ def generate_source_task(self):
elif type_ == "const":
type__ = field.rsplit("&")[0]
f.write(f"\t{type__} *task_data = new {type__}();\n")
f.write(f"\t*task_data = reply;\n")
f.write(f"\ttask.task_data = task_data;\n")
f.write("\t*task_data = reply;\n")
f.write("\ttask.task_data = task_data;\n")
elif type_ == "CUTRspInfoField":
f.write(f"\tif ({field})\n")
f.write("\t{\n")
f.write(f"\t\t{type_} *task_error = new {type_}();\n")
f.write(f"\t\t*task_error = *{field};\n")
f.write(f"\t\ttask.task_error = task_error;\n")
f.write("\t\ttask.task_error = task_error;\n")
f.write("\t}\n")
else:
f.write(f"\tif ({field})\n")
f.write("\t{\n")
f.write(f"\t\t{type_} *task_data = new {type_}();\n")
f.write(f"\t\t*task_data = *{field};\n")
f.write(f"\t\ttask.task_data = task_data;\n")
f.write("\t\ttask.task_data = task_data;\n")
f.write("\t}\n")

f.write(f"\tthis->task_queue.push(task);\n")
f.write("\tthis->task_queue.push(task);\n")
f.write("};\n\n")

def generate_source_switch(self):
Expand All @@ -196,7 +196,7 @@ def generate_source_switch(self):
f.write(f"case {name.upper()}:\n")
f.write("{\n")
f.write(f"\tthis->{process_name}(&task);\n")
f.write(f"\tbreak;\n")
f.write("\tbreak;\n")
f.write("}\n\n")

def generate_source_process(self):
Expand Down Expand Up @@ -347,7 +347,7 @@ def generate_source_on(self):
f.write("\t}\n")
f.write("\tcatch (const error_already_set &e)\n")
f.write("\t{\n")
f.write(f"\t\tcout << e.what() << endl;\n")
f.write("\t\tcout << e.what() << endl;\n")
f.write("\t}\n")
f.write("};\n\n")

Expand Down
2 changes: 1 addition & 1 deletion vnpy_ost/api/generator/generate_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def process_line(self, line: str):
self.process_declare(line)
elif line.startswith("};"):
self.process_end(line)
elif line.startswith("{") or "public:" in line or "()" in line or "memset" in line or "}"in line or line.startswith("//") or "// U" in line or "//买卖盘" in line or "//委托笔数揭示" in line:
elif line.startswith("{") or "public:" in line or "()" in line or "memset" in line or "}" in line or line.startswith("//") or "// U" in line or "//买卖盘" in line or "//委托笔数揭示" in line:
self.process_start(line)
elif "\t" in line and "///" not in line:
self.process_member(line)
Expand Down

0 comments on commit 2ab213b

Please sign in to comment.