Skip to content

Commit

Permalink
BUG: 修复库导入错误
Browse files Browse the repository at this point in the history
 - 包内使用相对导入
 - 包外使用绝对导入
  • Loading branch information
7Wate committed Nov 6, 2023
1 parent d163726 commit b5bee82
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from flask import Flask, render_template, redirect, url_for
from loguru import logger

import const
import models
import tools
from config import Config
from generator import Generator
from src import const
from src import models
from src import tools
from src.config import Config
from src.generator import Generator

app = Flask(__name__)
logger.add("endofyear.log")
Expand Down Expand Up @@ -41,7 +41,6 @@ def painting():
logger.info(f"Sentiment Post: {generator.sentiment_post()}")
logger.info(f"Long Post: {generator.long_post()}")
logger.info(f"Short Post: {generator.short_post()}")
logger.info(f"Custom: {custom}")

# 服务模式
if config.web_status == const.SITE_SERVICE_STATIC:
Expand Down
Empty file added src/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion src/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from lunardate import LunarDate
from snownlp import SnowNLP

import const
from . import const


# 计算文本内容情感分数
Expand Down
5 changes: 2 additions & 3 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import configparser
import json
import os
from urllib.parse import urlparse

from loguru import logger

import const
from src.tools import check_website_status
from . import const
from .tools import check_website_status


class Config:
Expand Down
4 changes: 2 additions & 2 deletions src/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from loguru import logger

import models
import scraper
from . import models
from . import scraper


@lru_cache(maxsize=None)
Expand Down
6 changes: 3 additions & 3 deletions src/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import feedparser
from loguru import logger

import analyzer
import const
import tools
from . import analyzer
from . import const
from . import tools


class Blog:
Expand Down
2 changes: 1 addition & 1 deletion src/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dateutil.parser import parse
from loguru import logger

import const
from . import const


def check_website_status(url):
Expand Down
2 changes: 1 addition & 1 deletion templates/painting.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h4>温馨提示</h4>
</div>
<div class="container animate__animated animate__fadeIn animate__slow" id="tab5">
<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-3s">{{ special_post.content[:50] }}<small>……</small>
</p>
Expand Down

0 comments on commit b5bee82

Please sign in to comment.