Skip to content

Commit

Permalink
修正 dispatcher 导入方式
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaass committed Sep 30, 2021
1 parent b2c5664 commit 4842c5b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions beancount_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from beancount_bot import dispatcher
from beancount_bot import transaction
from beancount_bot import builtin
from beancount_bot import util

__AUTHOR__ = 'KAAAsS'
__LICENSE__ = "MIT"
Expand Down
4 changes: 4 additions & 0 deletions beancount_bot/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
from beancount_bot.transaction import get_manager

from beancount_bot import bot, config as conf
from beancount_bot.config import load_config, get_config
Expand All @@ -22,6 +23,9 @@ def main(config):
# 加载会话
logger.info("加载会话...")
load_session()
# 创建管理对象
logger.info("创建管理对象...")
get_manager()
# 启动
logger.info("启动 Bot...")
bot.serving()
Expand Down
5 changes: 3 additions & 2 deletions beancount_bot/transaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import datetime
import importlib
import os
import sys
import time
import uuid
from typing import List, Tuple, Union
Expand Down Expand Up @@ -175,7 +175,8 @@ def create_manager():
for conf in get_config('transaction.message_dispatcher', []):
class_path = conf['class'].split('.')
module, classname = '.'.join(class_path[:-1]), class_path[-1]
clazz = getattr(importlib.import_module(module), classname)
__import__(module)
clazz = getattr(sys.modules[module], classname)
dispatchers.append(clazz(**conf['args']))
# 获得 Bean 文件位置
bean_file: str = get_config('transaction.beancount_file')
Expand Down

0 comments on commit 4842c5b

Please sign in to comment.