mirror of
https://gitee.com/xupingmao/xnote.git
synced 2025-12-06 11:39:11 +08:00
打包成模块
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -77,3 +77,8 @@ start-cmd.bat
|
||||
|
||||
# npm模块
|
||||
/static/lib/node_modules/
|
||||
|
||||
# pypi构建临时目录
|
||||
/build/
|
||||
/xnote.egg-info/
|
||||
/dist/
|
||||
12
MANIFEST.in
Normal file
12
MANIFEST.in
Normal file
@@ -0,0 +1,12 @@
|
||||
recursive-include static *
|
||||
recursive-include lib *
|
||||
recursive-include config *
|
||||
recursive-include docs *
|
||||
recursive-include handlers *
|
||||
|
||||
global-exclude htmlcov/*
|
||||
global-exclude data/*
|
||||
global-exclude *.py[cod]
|
||||
global-exclude __pycache__
|
||||
|
||||
recursive-exclude data *
|
||||
0
config/__init__.py
Normal file
0
config/__init__.py
Normal file
@@ -234,6 +234,7 @@ class HandlerManager:
|
||||
self.report_loading = False
|
||||
self.report_unload = True
|
||||
self.task_manager = CronTaskManager(app)
|
||||
|
||||
# stdout装饰器,方便读取print内容
|
||||
if not isinstance(sys.stdout, MyStdout):
|
||||
sys.stdout = MyStdout(sys.stdout)
|
||||
@@ -278,8 +279,8 @@ class HandlerManager:
|
||||
|
||||
# 重新加载HTTP处理器
|
||||
# 先全部卸载,然后全部加载,否则可能导致新的module依赖旧的module
|
||||
self.load_model_dir(xconfig.HANDLERS_DIR, unload=True, mod_name="handlers")
|
||||
self.load_model_dir(xconfig.HANDLERS_DIR, load=True, mod_name="handlers")
|
||||
self.load_model_dir(dirname=xconfig.HANDLERS_DIR, unload=True, mod_name="handlers")
|
||||
self.load_model_dir(dirname=xconfig.HANDLERS_DIR, load=True, mod_name="handlers")
|
||||
|
||||
# 重新加载定时任务
|
||||
self.load_tasks()
|
||||
@@ -308,20 +309,18 @@ class HandlerManager:
|
||||
mod = getattr(mod, name)
|
||||
return mod
|
||||
|
||||
def load_model_dir(self, parent=xconfig.HANDLERS_DIR, unload=False, load=False, mod_name="handlers"):
|
||||
if parent.startswith("./"):
|
||||
parent = parent[2:]
|
||||
dirname = parent.replace(".", "/")
|
||||
def load_model_dir(self, unload=False, load=False, mod_name="handlers", dirname=""):
|
||||
if not os.path.exists(dirname):
|
||||
logging.error("model_dir not found:%s", dirname)
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
for filename in os.listdir(dirname):
|
||||
filepath = os.path.join(dirname, filename)
|
||||
try:
|
||||
if os.path.isdir(filepath):
|
||||
self.load_model_dir(
|
||||
parent + "." + filename, unload=unload, load=load, mod_name=mod_name+"."+filename)
|
||||
subdir = os.path.join(dirname, filepath)
|
||||
self.load_model_dir(mod_name=mod_name+"."+filename, unload=unload, load=load, dirname=subdir)
|
||||
continue
|
||||
name, ext = os.path.splitext(filename)
|
||||
if os.path.isfile(filepath) and ext == ".py":
|
||||
|
||||
@@ -15,7 +15,7 @@ from xutils import dateutil
|
||||
from xutils.functions import del_dict_key
|
||||
from xtemplate import T
|
||||
from xutils.db.dbutil_helper import new_from_dict
|
||||
from xnote_core.service_tag import TagBindService, TagTypeEnum
|
||||
from xnote.service import TagBindService, TagTypeEnum
|
||||
from .message_model import is_task_tag
|
||||
|
||||
VALID_MESSAGE_PREFIX_TUPLE = ("message:", "msg_key:", "msg_task:")
|
||||
|
||||
@@ -15,7 +15,7 @@ from xutils import dateutil
|
||||
from xutils.db.dbutil_helper import PageBuilder, batch_iter
|
||||
from .dao_api import NoteDao
|
||||
from . import dao as note_dao
|
||||
from xnote_core.service_comment import CommentService
|
||||
from xnote.service import CommentService
|
||||
|
||||
NOTE_DAO = xutils.DAO("note")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
@email : 578749341@qq.com
|
||||
@Date : 2022-08-20 15:46:37
|
||||
@LastEditors : xupingmao
|
||||
@LastEditTime : 2023-09-19 23:52:00
|
||||
@LastEditTime : 2023-09-24 18:57:35
|
||||
@FilePath : /xnote/handlers/note/dao_tag.py
|
||||
@Description : 标签
|
||||
"""
|
||||
@@ -19,7 +19,7 @@ from xutils import functions
|
||||
from xutils import dbutil
|
||||
from xutils import attrget, Storage
|
||||
from handlers.note.dao_api import NoteDao
|
||||
from xnote_core.service_tag import TagBindService, TagTypeEnum
|
||||
from xnote.service import TagBindService, TagTypeEnum
|
||||
|
||||
tag_bind_db = dbutil.get_table("note_tags")
|
||||
tag_meta_db = dbutil.get_table("note_tag_meta")
|
||||
|
||||
0
lib/__init__.py
Normal file
0
lib/__init__.py
Normal file
32
setup.py
Normal file
32
setup.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# encoding=utf-8
|
||||
|
||||
import setuptools
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as fp:
|
||||
long_description = fp.read()
|
||||
|
||||
|
||||
data_ext_list = ["*.txt", "*.json", "*.properties", "*.js", "*.html", "*.css"]
|
||||
|
||||
setuptools.setup(
|
||||
name = "xnote",
|
||||
version = "0.0.1",
|
||||
author = "mark",
|
||||
author_email = "578749341@qq.com",
|
||||
description = "xnote-web框架",
|
||||
long_description = long_description,
|
||||
long_description_content_type = "text/markdown",
|
||||
# packages = ["config", "core", "docs", "handlers", "lib", "static", "tools", "xnote", "xutils"],
|
||||
packages=setuptools.find_packages(),
|
||||
include_package_data=True, # 包含资源文件
|
||||
# package_dir={"": "."},
|
||||
# package_data={
|
||||
# "": data_ext_list,
|
||||
# "handlers": data_ext_list,
|
||||
# },
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
)
|
||||
0
static/__init__.py
Normal file
0
static/__init__.py
Normal file
@@ -337,7 +337,7 @@ class TestMain(BaseTestCase):
|
||||
|
||||
self.assertEqual(note_info.tags, ["ABC", "DEF"])
|
||||
|
||||
from xnote_core.service_tag import TagBindService, TagTypeEnum
|
||||
from xnote.service import TagBindService, TagTypeEnum
|
||||
user_info = xauth.current_user()
|
||||
assert user_info != None
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ def run_test(args):
|
||||
check_and_install_pkg("lmdb", "lmdb==1.4.1")
|
||||
if os.name != "nt":
|
||||
check_and_install_pkg("leveldb", "leveldb==0.201")
|
||||
os.system("%s -m pytest tests --doctest-modules --cov handlers --cov xutils --cov core --cov xnote_core --ff" % executable)
|
||||
os.system("%s -m pytest tests --doctest-modules --cov handlers --cov xutils --cov core --cov xnote --ff" % executable)
|
||||
os.system("%s -m coverage html -i" % executable)
|
||||
|
||||
def main():
|
||||
|
||||
3
xnote/__init__.py
Normal file
3
xnote/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# encoding=utf-8
|
||||
|
||||
"""xnote-web框架"""
|
||||
14
xnote/service/__init__.py
Normal file
14
xnote/service/__init__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
"""
|
||||
@Author : xupingmao
|
||||
@email : 578749341@qq.com
|
||||
@Date : 2023-09-24 18:57:07
|
||||
@LastEditors : xupingmao
|
||||
@LastEditTime : 2023-09-24 18:58:08
|
||||
@FilePath : /xnote/xnote/service/__init__.py
|
||||
@Description : 描述
|
||||
"""
|
||||
# encoding=utf-8
|
||||
|
||||
from .service_comment import *
|
||||
from .service_tag import *
|
||||
Reference in New Issue
Block a user