BUG: 修复库导入错误

- 包内使用相对导入
 - 包外使用绝对导入
This commit is contained in:
周中平 2023-11-06 16:24:08 +08:00
parent d163726756
commit b5bee828ca
Signed by: zhouzhongping
GPG Key ID: 6666822800008000
8 changed files with 15 additions and 17 deletions

11
main.py
View File

@ -1,11 +1,11 @@
from flask import Flask, render_template, redirect, url_for from flask import Flask, render_template, redirect, url_for
from loguru import logger from loguru import logger
import const from src import const
import models from src import models
import tools from src import tools
from config import Config from src.config import Config
from generator import Generator from src.generator import Generator
app = Flask(__name__) app = Flask(__name__)
logger.add("endofyear.log") logger.add("endofyear.log")
@ -41,7 +41,6 @@ def painting():
logger.info(f"Sentiment Post: {generator.sentiment_post()}") logger.info(f"Sentiment Post: {generator.sentiment_post()}")
logger.info(f"Long Post: {generator.long_post()}") logger.info(f"Long Post: {generator.long_post()}")
logger.info(f"Short Post: {generator.short_post()}") logger.info(f"Short Post: {generator.short_post()}")
logger.info(f"Custom: {custom}")
# 服务模式 # 服务模式
if config.web_status == const.SITE_SERVICE_STATIC: if config.web_status == const.SITE_SERVICE_STATIC:

0
src/__init__.py Normal file
View File

View File

@ -5,7 +5,7 @@ from loguru import logger
from lunardate import LunarDate from lunardate import LunarDate
from snownlp import SnowNLP from snownlp import SnowNLP
import const from . import const
# 计算文本内容情感分数 # 计算文本内容情感分数

View File

@ -1,12 +1,11 @@
import configparser import configparser
import json
import os import os
from urllib.parse import urlparse from urllib.parse import urlparse
from loguru import logger from loguru import logger
import const from . import const
from src.tools import check_website_status from .tools import check_website_status
class Config: class Config:

View File

@ -2,8 +2,8 @@ from functools import lru_cache
from loguru import logger from loguru import logger
import models from . import models
import scraper from . import scraper
@lru_cache(maxsize=None) @lru_cache(maxsize=None)

View File

@ -4,9 +4,9 @@ from collections import Counter
import feedparser import feedparser
from loguru import logger from loguru import logger
import analyzer from . import analyzer
import const from . import const
import tools from . import tools
class Blog: class Blog:

View File

@ -7,7 +7,7 @@ from bs4 import BeautifulSoup
from dateutil.parser import parse from dateutil.parser import parse
from loguru import logger from loguru import logger
import const from . import const
def check_website_status(url): def check_website_status(url):

View File

@ -79,7 +79,7 @@
</div> </div>
<div class="container animate__animated animate__fadeIn animate__slow" id="tab5"> <div class="container animate__animated animate__fadeIn animate__slow" id="tab5">
<div class="tab5-box"> <div class="tab5-box">
<p class="animate__animated animate__fadeInDown animate__delay-1s">在{{ special_post.date }}那天,写下了</p> <p class="animate__animated animate__fadeInDown animate__delay-1s">在{{ special_post.date }}那天,写下了</p>
<p class="animate__animated animate__fadeInDown animate__delay-2s">{{ special_post.title }}</p> <p class="animate__animated animate__fadeInDown animate__delay-2s">{{ special_post.title }}</p>
<p class="animate__animated animate__fadeInDown animate__delay-3s">{{ special_post.content[:50] }}<small>……</small> <p class="animate__animated animate__fadeInDown animate__delay-3s">{{ special_post.content[:50] }}<small>……</small>
</p> </p>