Skip to content

Commit

Permalink
circular dep fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed Apr 20, 2024
1 parent e4b3908 commit 001c8aa
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
Empty file added app/models/__init__.py
Empty file.
14 changes: 7 additions & 7 deletions app/models/column.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions app/models/feed.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from collections import defaultdict
import time

import dateutil
import feedparser
import importlib
import json
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)
Expand Down
23 changes: 11 additions & 12 deletions app/models/layout.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
13 changes: 6 additions & 7 deletions app/models/row.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 001c8aa

Please sign in to comment.