Merge branch 'DEV' of https://github.com/vnpy/vnpy into DEV

This commit is contained in:
vn.py 2019-04-11 15:25:59 +08:00
commit 6c15a50599
3 changed files with 11 additions and 12 deletions

View File

@ -197,13 +197,11 @@ class BaseEngine(ABC):
pass pass
class LogEngine(BaseEngine): class LogEngine(BaseEngine, metaclass=Singleton):
""" """
Processes log event and output with logging module. Processes log event and output with logging module.
""" """
__metaclass__ = Singleton
def __init__(self, main_engine: MainEngine, event_engine: EventEngine): def __init__(self, main_engine: MainEngine, event_engine: EventEngine):
"""""" """"""
super(LogEngine, self).__init__(main_engine, event_engine, "log") super(LogEngine, self).__init__(main_engine, event_engine, "log")

View File

@ -24,7 +24,7 @@ from .widget import (
AboutDialog, AboutDialog,
) )
from ..engine import MainEngine from ..engine import MainEngine
from ..utility import get_icon_path, TRADER_PATH from ..utility import get_icon_path, TRADER_DIR
class MainWindow(QtWidgets.QMainWindow): class MainWindow(QtWidgets.QMainWindow):
@ -38,7 +38,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.main_engine = main_engine self.main_engine = main_engine
self.event_engine = event_engine self.event_engine = event_engine
self.window_title = f"VN Trader [{TRADER_PATH}]" self.window_title = f"VN Trader [{TRADER_DIR}]"
self.connect_dialogs = {} self.connect_dialogs = {}
self.widgets = {} self.widgets = {}

View File

@ -14,10 +14,11 @@ from .object import BarData, TickData
class Singleton(type): class Singleton(type):
""" """
Singleton metaclass, Singleton metaclass,
class A: usage:
__metaclass__ = Singleton class A(metaclass=Singleton):
...
""" """
_instances = {} _instances = {}
@ -30,7 +31,7 @@ class Singleton(type):
return cls._instances[cls] return cls._instances[cls]
def get_path(temp_name: str): def _get_trader_dir(temp_name: str):
""" """
Get path where trader is running in. Get path where trader is running in.
""" """
@ -53,21 +54,21 @@ def get_path(temp_name: str):
return home_path, temp_path return home_path, temp_path
TRADER_PATH, TEMP_PATH = get_path(".vntrader") TRADER_DIR, TEMP_DIR = _get_trader_dir(".vntrader")
def get_file_path(filename: str): def get_file_path(filename: str):
""" """
Get path for temp file with filename. Get path for temp file with filename.
""" """
return TEMP_PATH.joinpath(filename) return TEMP_DIR.joinpath(filename)
def get_folder_path(folder_name: str): def get_folder_path(folder_name: str):
""" """
Get path for temp folder with folder name. Get path for temp folder with folder name.
""" """
folder_path = TEMP_PATH.joinpath(folder_name) folder_path = TEMP_DIR.joinpath(folder_name)
if not folder_path.exists(): if not folder_path.exists():
folder_path.mkdir() folder_path.mkdir()
return folder_path return folder_path