From 836b91aa67105f6bb18239364d4bf655816152b9 Mon Sep 17 00:00:00 2001 From: MathiasDPX Date: Wed, 5 Mar 2025 16:46:56 +0100 Subject: [PATCH] fix: pylint --- main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index b5093f5..9ade4c0 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,18 @@ +import json +import re +import os from flask import Flask, render_template, request, send_file, make_response -from routes.editor import editor_routes from feedgen.feed import FeedGenerator from dotenv import load_dotenv +from routes.editor import editor_routes from classes import * -import json, re, os load_dotenv() app = Flask(__name__) app.register_blueprint(editor_routes) -articles_data = json.load(open("articles.json", "r", encoding="utf-8")) +with open("articles.json", "r", encoding="utf-8") as f: + articles_data = json.load(f) categories = {} # Category name:str -> [Article] articles = {} # ID:str = Article @@ -23,16 +26,15 @@ fg.description("Blog RSS feed") for article_data in articles_data: category_name = article_data.get("category", "Uncategorized") - category_list = categories.get(category_name, []) - + article = Article( template=article_data.get("template"), title=article_data.get("title"), category=category_name ) - - if article.template in list(articles.keys()): + + if article.template in articles.keys(): raise KeyError(f"Two articles linking to the same template ({article.template})") articles[article.template] = article @@ -79,4 +81,4 @@ def article(article_id:str): return render_template(f"articles/{article.template}.html") if __name__ == "__main__": - app.run() \ No newline at end of file + app.run()