From 001c8aa2608efe614e2a37cdc279812445bfbb1b Mon Sep 17 00:00:00 2001 From: mike <219478+ilude@users.noreply.github.com> Date: Fri, 19 Apr 2024 20:11:13 -0400 Subject: [PATCH] circular dep fixes --- app/models/__init__.py | 0 app/models/column.py | 14 +++++++------- app/models/feed.py | 14 +++++++------- app/models/layout.py | 23 +++++++++++------------ app/models/row.py | 13 ++++++------- 5 files changed, 31 insertions(+), 33 deletions(-) create mode 100644 app/models/__init__.py diff --git a/app/models/__init__.py b/app/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/models/column.py b/app/models/column.py index c9eccc5..4759562 100644 --- a/app/models/column.py +++ b/app/models/column.py @@ -1,17 +1,17 @@ - from models.utils import from_list +import models.row +import models.widget class Column: - rows: list['Row'] = [] - widgets: list['Widget'] = [] + + rows: list['models.row.Row'] = [] + widgets: list['models.widget.Widget'] = [] @staticmethod def from_dict(dictionary: dict) -> 'Column': - from models.row import Row - from models.widget import Widget column = Column() if 'rows' in dictionary: - column.rows = from_list(Row.from_dict, dictionary['rows']) + column.rows = from_list(models.row.Row.from_dict, dictionary['rows']) if 'widgets' in dictionary: - column.widgets = from_list(Widget.from_dict, dictionary['widgets']) + column.widgets = from_list(models.widget.Widget.from_dict, dictionary['widgets']) return column diff --git a/app/models/feed.py b/app/models/feed.py index f8c2539..c205d37 100644 --- a/app/models/feed.py +++ b/app/models/feed.py @@ -1,5 +1,4 @@ -from collections import defaultdict -import time + import dateutil import feedparser import importlib @@ -7,16 +6,17 @@ import logging import os -from datetime import datetime, timedelta, timezone -from email.utils import formatdate +from collections import defaultdict +from datetime import datetime, timedelta from email import utils +from email.utils import formatdate from functools import cached_property from pathlib import Path -from models.noop_feed_processor import NoOpFeedProcessor -from models.feed_article import FeedArticle -from models.utils import calculate_sha1_hash, to_snake_case, pwd +from models.utils import calculate_sha1_hash, pwd, to_snake_case from models.widget import Widget +from models.feed_article import FeedArticle +from models.noop_feed_processor import NoOpFeedProcessor logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) diff --git a/app/models/layout.py b/app/models/layout.py index 5f05f8c..7963ac5 100644 --- a/app/models/layout.py +++ b/app/models/layout.py @@ -1,20 +1,21 @@ import logging import os -from models.column import Column +import yaml +from models.bookmark import Bookmark from models.row import Row +from models.column import Column from models.scheduler import Scheduler -from models.utils import pwd - -import yaml -from models.utils import from_list +from models.tab import Tab +from models.feed import Feed +from models.utils import from_list, pwd logger = logging.getLogger(__name__) class Layout: id: str = 'layout' - headers: list['Bookmark'] = [] - tabs: list['Tab'] = [] + headers: list[Bookmark] = [] + tabs: list[Tab] = [] def __init__(self, config_file: str = "configs/layout.yml"): logger.setLevel(logging.DEBUG) @@ -38,8 +39,6 @@ def mtime(self): def reload(self): - from models.tab import Tab - from models.bookmark import Bookmark Scheduler.clear_jobs() with open(self.config_path, 'r') as file: @@ -53,14 +52,14 @@ def reload(self): - def tab(self, name: str) -> 'Tab': + def tab(self, name: str) -> Tab: if name is None: return self.tabs[0] return next((tab for tab in self.tabs if tab.name.lower() == name.lower()), self.tabs[0]) - def get_feeds(self, columns: 'Column') -> list['Feed']: + def get_feeds(self, columns: Column) -> list[Feed]: feeds = [] if columns.rows: for row in columns.rows: @@ -74,7 +73,7 @@ def get_feeds(self, columns: 'Column') -> list['Feed']: return feeds - def get_feed(self, feed_id: str) -> 'Feed': + def get_feed(self, feed_id: str) -> Feed: if not self.feed_hash: feeds = [] for tab in self.tabs: diff --git a/app/models/row.py b/app/models/row.py index 4358b11..19bb5f1 100644 --- a/app/models/row.py +++ b/app/models/row.py @@ -1,18 +1,17 @@ from models.utils import from_list - +import models.column +import models.widget class Row: - columns: list['Column'] = [] + columns: list['models.column.Column'] = [] @staticmethod def from_dict(dictionary: dict) -> 'Row': - from models.column import Column - from models.widget import Widget row = Row() if 'columns' in dictionary: - row.columns = from_list(Column.from_dict, dictionary['columns']) + row.columns = from_list(models.column.Column.from_dict, dictionary['columns']) else: - column = Column() - column.widgets = from_list(Widget.from_dict, dictionary['widgets']) + column = models.column.Column() + column.widgets = from_list(models.widget.Widget.from_dict, dictionary['widgets']) row.columns = [column] return row \ No newline at end of file