⚡ 添加liteyuki.channel.Channel通道,可安全跨进程通信
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
import inspect
|
||||
import os
|
||||
import pickle
|
||||
import sqlite3
|
||||
from types import NoneType
|
||||
from typing import Any, Callable
|
||||
from packaging.version import parse
|
||||
import inspect
|
||||
import nonebot
|
||||
import pydantic
|
||||
|
||||
from nonebot import logger
|
||||
from nonebot.compat import PYDANTIC_V2
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@ -15,10 +15,10 @@ class LiteModel(BaseModel):
|
||||
id: int = None
|
||||
|
||||
def dump(self, *args, **kwargs):
|
||||
if parse(pydantic.__version__) < parse("2.0.0"):
|
||||
return self.dict(*args, **kwargs)
|
||||
else:
|
||||
if PYDANTIC_V2:
|
||||
return self.model_dump(*args, **kwargs)
|
||||
else:
|
||||
return self.dict(*args, **kwargs)
|
||||
|
||||
|
||||
class Database:
|
||||
@ -60,7 +60,7 @@ class Database:
|
||||
"""
|
||||
table_name = model.TABLE_NAME
|
||||
model_type = type(model)
|
||||
nonebot.logger.debug(f"Selecting {model.TABLE_NAME} WHERE {condition.replace('?', '%s') % args}")
|
||||
logger.debug(f"Selecting {model.TABLE_NAME} WHERE {condition.replace('?', '%s') % args}")
|
||||
if not table_name:
|
||||
raise ValueError(f"数据模型{model_type.__name__}未提供表名")
|
||||
|
||||
@ -88,7 +88,7 @@ class Database:
|
||||
"""
|
||||
table_list = [item[0] for item in self.cursor.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()]
|
||||
for model in args:
|
||||
nonebot.logger.debug(f"Upserting {model}")
|
||||
logger.debug(f"Upserting {model}")
|
||||
if not model.TABLE_NAME:
|
||||
raise ValueError(f"数据模型 {model.__class__.__name__} 未提供表名")
|
||||
elif model.TABLE_NAME not in table_list:
|
||||
@ -206,7 +206,7 @@ class Database:
|
||||
|
||||
"""
|
||||
table_name = model.TABLE_NAME
|
||||
nonebot.logger.debug(f"Deleting {model} WHERE {condition} {args}")
|
||||
logger.debug(f"Deleting {model} WHERE {condition} {args}")
|
||||
if not table_name:
|
||||
raise ValueError(f"数据模型{model.__class__.__name__}未提供表名")
|
||||
if model.id is not None:
|
||||
|
Reference in New Issue
Block a user