Merge pull request #875 from cclauss/modernize-vnpy_api_k
Modernize vnpy/api/k*
This commit is contained in:
commit
8569f7ddfc
@ -1,4 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnksgoldtd import TdApi
|
||||
from ksgold_data_type import defineDict
|
||||
from __future__ import absolute_import
|
||||
from .vnksgoldtd import TdApi
|
||||
from .ksgold_data_type import defineDict
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
# C++和python类型的映射字典
|
||||
@ -48,7 +49,7 @@ def process_typedef(line):
|
||||
else:
|
||||
keyword = content[-1]
|
||||
keyword = keyword.replace(';\n', '')
|
||||
print content, keyword
|
||||
print(content, keyword)
|
||||
|
||||
if '[' in keyword:
|
||||
i = keyword.index('[')
|
||||
@ -91,15 +92,15 @@ def main():
|
||||
py_line = process_line(line)
|
||||
if py_line:
|
||||
fpy.write(py_line.decode('gbk').encode('utf-8'))
|
||||
print n
|
||||
print(n)
|
||||
|
||||
fcpp.close()
|
||||
fpy.close()
|
||||
|
||||
print u'data_type.py生成过程完成'
|
||||
except Exception, e:
|
||||
print u'data_type.py生成过程出错'
|
||||
print e
|
||||
print(u'data_type.py生成过程完成')
|
||||
except Exception as e:
|
||||
print(u'data_type.py生成过程出错')
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from ksgold_data_type import *
|
||||
@ -47,7 +48,7 @@ def main():
|
||||
n = line.index('//')
|
||||
line = line[:n]
|
||||
|
||||
print no, ':', line
|
||||
print(no, ':', line)
|
||||
|
||||
content = line.split('\t')
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from vnksotpmd import MdApi
|
||||
from vnksotptd import TdApi
|
||||
from ksotp_data_type import defineDict
|
||||
from __future__ import absolute_import
|
||||
from .vnksotpmd import MdApi
|
||||
from .vnksotptd import TdApi
|
||||
from .ksotp_data_type import defineDict
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
# C++和python类型的映射字典
|
||||
@ -88,9 +89,9 @@ def main():
|
||||
fcpp.close()
|
||||
fpy.close()
|
||||
|
||||
print u'data_type.py生成过程完成'
|
||||
print(u'data_type.py生成过程完成')
|
||||
except:
|
||||
print u'data_type.py生成过程出错'
|
||||
print(u'data_type.py生成过程出错')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from ksotp_data_type import *
|
||||
@ -15,7 +16,7 @@ def main():
|
||||
fpy.write('\n')
|
||||
|
||||
for n, line in enumerate(fcpp):
|
||||
print n
|
||||
print(n)
|
||||
# 结构体申明注释
|
||||
if '///' in line and '\t' not in line:
|
||||
py_line = '#' + line[3:]
|
||||
@ -38,8 +39,8 @@ def main():
|
||||
try:
|
||||
type_ = typedefDict[typedef]
|
||||
except KeyError:
|
||||
print content
|
||||
print typedef
|
||||
print(content)
|
||||
print(typedef)
|
||||
|
||||
variable = content[2].replace(';\n', "")
|
||||
py_line = '%s["%s"] = "%s"\n' % (name, variable, type_)
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
@ -12,15 +13,15 @@ from vnksotpmd import *
|
||||
def print_dict(d):
|
||||
"""按照键值打印一个字典"""
|
||||
for key,value in d.items():
|
||||
print key + ':' + str(value)
|
||||
print(key + ':' + str(value))
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def simple_log(func):
|
||||
"""简单装饰器用于输出函数名"""
|
||||
def wrapper(*args, **kw):
|
||||
print ""
|
||||
print str(func.__name__)
|
||||
print("")
|
||||
print(str(func.__name__))
|
||||
return func(*args, **kw)
|
||||
return wrapper
|
||||
|
||||
@ -44,7 +45,7 @@ class TestMdApi(MdApi):
|
||||
@simple_log
|
||||
def onFrontDisconnected(self, n):
|
||||
"""服务器断开"""
|
||||
print n
|
||||
print(n)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
|
@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
@ -11,15 +12,15 @@ from vnksotptd import *
|
||||
def print_dict(d):
|
||||
"""按照键值打印一个字典"""
|
||||
for key,value in d.items():
|
||||
print key + ':' + str(value)
|
||||
print(key + ':' + str(value))
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def simple_log(func):
|
||||
"""简单装饰器用于输出函数名"""
|
||||
def wrapper(*args, **kw):
|
||||
print ""
|
||||
print str(func.__name__)
|
||||
print("")
|
||||
print(str(func.__name__))
|
||||
return func(*args, **kw)
|
||||
return wrapper
|
||||
|
||||
@ -43,7 +44,7 @@ class TestTdApi(TdApi):
|
||||
@simple_log
|
||||
def onFrontDisconnected(self, n):
|
||||
"""服务器断开"""
|
||||
print n
|
||||
print(n)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
@ -89,8 +90,8 @@ class TestTdApi(TdApi):
|
||||
"""查询合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
print n
|
||||
print last
|
||||
print(n)
|
||||
print(last)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user