aboutsummaryrefslogtreecommitdiff
path: root/newspipe
diff options
context:
space:
mode:
Diffstat (limited to 'newspipe')
-rw-r--r--newspipe/bootstrap.py8
-rw-r--r--newspipe/controllers/abstract.py10
-rw-r--r--newspipe/controllers/article.py8
-rw-r--r--newspipe/controllers/bookmark.py3
-rw-r--r--newspipe/controllers/category.py3
-rw-r--r--newspipe/controllers/feed.py7
-rw-r--r--newspipe/controllers/icon.py3
-rw-r--r--newspipe/controllers/tag.py5
-rw-r--r--newspipe/controllers/user.py7
-rw-r--r--newspipe/crawler/default_crawler.py20
-rw-r--r--newspipe/lib/data.py10
-rw-r--r--newspipe/lib/feed_utils.py7
-rwxr-xr-xnewspipe/lib/misc_utils.py22
-rw-r--r--newspipe/lib/utils.py5
-rw-r--r--newspipe/models/__init__.py28
-rw-r--r--newspipe/models/article.py3
-rw-r--r--newspipe/models/bookmark.py7
-rw-r--r--newspipe/models/category.py3
-rw-r--r--newspipe/models/feed.py8
-rw-r--r--newspipe/models/user.py5
-rw-r--r--newspipe/notifications/notifications.py1
-rw-r--r--newspipe/web/decorators.py2
-rw-r--r--newspipe/web/forms.py18
-rw-r--r--newspipe/web/lib/view_utils.py4
-rw-r--r--newspipe/web/views/__init__.py8
-rw-r--r--newspipe/web/views/admin.py11
-rw-r--r--newspipe/web/views/api/v2/__init__.py2
-rw-r--r--newspipe/web/views/api/v2/article.py9
-rw-r--r--newspipe/web/views/api/v2/category.py2
-rw-r--r--newspipe/web/views/api/v2/common.py9
-rw-r--r--newspipe/web/views/api/v2/feed.py11
-rw-r--r--newspipe/web/views/article.py21
-rw-r--r--newspipe/web/views/bookmark.py16
-rw-r--r--newspipe/web/views/category.py12
-rw-r--r--newspipe/web/views/common.py8
-rw-r--r--newspipe/web/views/feed.py26
-rw-r--r--newspipe/web/views/home.py24
-rw-r--r--newspipe/web/views/icon.py1
-rw-r--r--newspipe/web/views/session_mgmt.py26
-rw-r--r--newspipe/web/views/user.py27
-rw-r--r--newspipe/web/views/views.py14
41 files changed, 246 insertions, 178 deletions
diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py
index 293a7362..fd0577b3 100644
--- a/newspipe/bootstrap.py
+++ b/newspipe/bootstrap.py
@@ -3,10 +3,12 @@
# required imports and code execution for basic functionning
-import os
import logging
-from flask import request
+import os
+
+from flask import Flask, request
from flask_babel import Babel, format_datetime
+from flask_sqlalchemy import SQLAlchemy
def set_logging(
@@ -43,8 +45,6 @@ def set_logging(
logger.setLevel(log_level)
-from flask import Flask
-from flask_sqlalchemy import SQLAlchemy
# Create Flask application
application = Flask(__name__, instance_relative_config=True)
diff --git a/newspipe/controllers/abstract.py b/newspipe/controllers/abstract.py
index 32d07170..6401763b 100644
--- a/newspipe/controllers/abstract.py
+++ b/newspipe/controllers/abstract.py
@@ -1,11 +1,13 @@
import logging
-import dateutil.parser
-from newspipe.bootstrap import db
-from datetime import datetime
from collections import defaultdict
-from sqlalchemy import or_, func
+from datetime import datetime
+
+import dateutil.parser
+from sqlalchemy import func, or_
from werkzeug.exceptions import Forbidden, NotFound
+from newspipe.bootstrap import db
+
logger = logging.getLogger(__name__)
diff --git a/newspipe/controllers/article.py b/newspipe/controllers/article.py
index 5a017bfa..8468248e 100644
--- a/newspipe/controllers/article.py
+++ b/newspipe/controllers/article.py
@@ -1,14 +1,16 @@
import logging
+from collections import Counter
+
import sqlalchemy
from sqlalchemy import func
-from collections import Counter
from newspipe.bootstrap import db
-from .abstract import AbstractController
-from newspipe.lib.article_utils import process_filters
from newspipe.controllers import CategoryController, FeedController
+from newspipe.lib.article_utils import process_filters
from newspipe.models import Article
+from .abstract import AbstractController
+
logger = logging.getLogger(__name__)
diff --git a/newspipe/controllers/bookmark.py b/newspipe/controllers/bookmark.py
index d708491a..41a59a56 100644
--- a/newspipe/controllers/bookmark.py
+++ b/newspipe/controllers/bookmark.py
@@ -1,8 +1,9 @@
-import logging
import itertools
+import logging
from newspipe.bootstrap import db
from newspipe.models import Bookmark
+
from .abstract import AbstractController
from .tag import BookmarkTagController
diff --git a/newspipe/controllers/category.py b/newspipe/controllers/category.py
index 36f1dea2..dc140a7b 100644
--- a/newspipe/controllers/category.py
+++ b/newspipe/controllers/category.py
@@ -1,5 +1,6 @@
-from .abstract import AbstractController
from newspipe.models import Category
+
+from .abstract import AbstractController
from .feed import FeedController
diff --git a/newspipe/controllers/feed.py b/newspipe/controllers/feed.py
index 73f852a8..0f3f03e7 100644
--- a/newspipe/controllers/feed.py
+++ b/newspipe/controllers/feed.py
@@ -1,12 +1,13 @@
-import logging
import itertools
+import logging
from datetime import datetime, timedelta
from newspipe.bootstrap import application
+from newspipe.lib.utils import clear_string
+from newspipe.models import Feed, User
+
from .abstract import AbstractController
from .icon import IconController
-from newspipe.models import User, Feed
-from newspipe.lib.utils import clear_string
logger = logging.getLogger(__name__)
DEFAULT_LIMIT = 5
diff --git a/newspipe/controllers/icon.py b/newspipe/controllers/icon.py
index 0fa7a39e..d5dd7fe6 100644
--- a/newspipe/controllers/icon.py
+++ b/newspipe/controllers/icon.py
@@ -1,6 +1,9 @@
import base64
+
import requests
+
from newspipe.models import Icon
+
from .abstract import AbstractController
diff --git a/newspipe/controllers/tag.py b/newspipe/controllers/tag.py
index 4f6fabbe..7a392949 100644
--- a/newspipe/controllers/tag.py
+++ b/newspipe/controllers/tag.py
@@ -1,10 +1,11 @@
-import logging
import itertools
+import logging
from newspipe.bootstrap import db
-from .abstract import AbstractController
from newspipe.models.tag import BookmarkTag
+from .abstract import AbstractController
+
logger = logging.getLogger(__name__)
diff --git a/newspipe/controllers/user.py b/newspipe/controllers/user.py
index 7396e52c..76908a73 100644
--- a/newspipe/controllers/user.py
+++ b/newspipe/controllers/user.py
@@ -1,8 +1,11 @@
import logging
-from werkzeug.security import generate_password_hash, check_password_hash
-from .abstract import AbstractController
+
+from werkzeug.security import check_password_hash, generate_password_hash
+
from newspipe.models import User
+from .abstract import AbstractController
+
logger = logging.getLogger(__name__)
diff --git a/newspipe/crawler/default_crawler.py b/newspipe/crawler/default_crawler.py
index ccdef274..8408a845 100644
--- a/newspipe/crawler/default_crawler.py
+++ b/newspipe/crawler/default_crawler.py
@@ -26,25 +26,25 @@ __revision__ = "$Date: 2019/05/21 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "AGPLv3"
-import io
import asyncio
+import io
import logging
-import feedparser
-import dateutil.parser
from datetime import datetime, timedelta
+
+import dateutil.parser
+import feedparser
from sqlalchemy import or_
-from newspipe.bootstrap import application
-from newspipe.bootstrap import db
-from newspipe.models import User
-from newspipe.controllers import FeedController, ArticleController
-from newspipe.lib.utils import newspipe_get
-from newspipe.lib.feed_utils import construct_feed_from, is_parsing_ok
+from newspipe.bootstrap import application, db
+from newspipe.controllers import ArticleController, FeedController
from newspipe.lib.article_utils import (
construct_article,
extract_id,
- get_article_content,
+ get_article_content
)
+from newspipe.lib.feed_utils import construct_feed_from, is_parsing_ok
+from newspipe.lib.utils import newspipe_get
+from newspipe.models import User
logger = logging.getLogger(__name__)
diff --git a/newspipe/lib/data.py b/newspipe/lib/data.py
index 61c481d1..52d05cd2 100644
--- a/newspipe/lib/data.py
+++ b/newspipe/lib/data.py
@@ -30,17 +30,17 @@ __license__ = "AGPLv3"
# This file contains the import/export functions of Newspipe.
#
+import datetime
import json
-import opml
import logging
-import datetime
+
+import opml
from flask import jsonify
from newspipe.bootstrap import db
-from newspipe.models import User, Feed, Article
-from newspipe.models.tag import BookmarkTag
from newspipe.controllers import BookmarkController, BookmarkTagController
-
+from newspipe.models import Article, Feed, User
+from newspipe.models.tag import BookmarkTag
logger = logging.getLogger(__name__)
diff --git a/newspipe/lib/feed_utils.py b/newspipe/lib/feed_utils.py
index 55cb6205..995bfaae 100644
--- a/newspipe/lib/feed_utils.py
+++ b/newspipe/lib/feed_utils.py
@@ -1,12 +1,13 @@
import html
-import urllib
import logging
-import requests
+import urllib
+
import feedparser
+import requests
from bs4 import BeautifulSoup, SoupStrainer
from newspipe.bootstrap import application
-from newspipe.lib.utils import try_keys, try_get_icon_url, rebuild_url
+from newspipe.lib.utils import rebuild_url, try_get_icon_url, try_keys
logger = logging.getLogger(__name__)
logging.captureWarnings(True)
diff --git a/newspipe/lib/misc_utils.py b/newspipe/lib/misc_utils.py
index 1a423466..1e246757 100755
--- a/newspipe/lib/misc_utils.py
+++ b/newspipe/lib/misc_utils.py
@@ -26,28 +26,30 @@ __revision__ = "$Date: 2016/11/22 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "AGPLv3"
-import re
-import os
-import sys
import glob
import logging
import operator
-import urllib
+import os
+import re
import subprocess
-import sqlalchemy
-
-try:
- from urlparse import urlparse, parse_qs, urlunparse
-except:
- from urllib.parse import urlparse, parse_qs, urlunparse, urljoin
+import sys
+import urllib
from collections import Counter
from contextlib import contextmanager
+
+import sqlalchemy
from flask import request
from newspipe.bootstrap import application
from newspipe.controllers import ArticleController
from newspipe.lib.utils import clear_string
+try:
+ from urlparse import urlparse, parse_qs, urlunparse
+except:
+ from urllib.parse import urlparse, parse_qs, urlunparse, urljoin
+
+
logger = logging.getLogger(__name__)
ALLOWED_EXTENSIONS = set(["xml", "opml", "json"])
diff --git a/newspipe/lib/utils.py b/newspipe/lib/utils.py
index 67ced60d..3d6bf0b8 100644
--- a/newspipe/lib/utils.py
+++ b/newspipe/lib/utils.py
@@ -1,9 +1,10 @@
+import logging
import re
import types
import urllib
-import logging
-import requests
from hashlib import md5
+
+import requests
from flask import request, url_for
from newspipe.bootstrap import application
diff --git a/newspipe/models/__init__.py b/newspipe/models/__init__.py
index 6b64b4cc..a820a43b 100644
--- a/newspipe/models/__init__.py
+++ b/newspipe/models/__init__.py
@@ -26,15 +26,23 @@ __revision__ = "$Date: 2014/04/12 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
+from sqlalchemy.engine import reflection
+from sqlalchemy.schema import (
+ DropConstraint,
+ DropTable,
+ ForeignKeyConstraint,
+ MetaData,
+ Table
+)
+
+from .article import Article
+from .bookmark import Bookmark
+from .category import Category
from .feed import Feed
+from .icon import Icon
from .role import Role
+from .tag import ArticleTag, BookmarkTag
from .user import User
-from .article import Article
-from .icon import Icon
-from .category import Category
-from .tag import BookmarkTag
-from .tag import ArticleTag
-from .bookmark import Bookmark
__all__ = [
"Feed",
@@ -49,14 +57,6 @@ __all__ = [
]
-from sqlalchemy.engine import reflection
-from sqlalchemy.schema import (
- MetaData,
- Table,
- DropTable,
- ForeignKeyConstraint,
- DropConstraint,
-)
def db_empty(db):
diff --git a/newspipe/models/article.py b/newspipe/models/article.py
index 0a747a30..78efd9e2 100644
--- a/newspipe/models/article.py
+++ b/newspipe/models/article.py
@@ -26,11 +26,12 @@ __revision__ = "$Date: 2016/10/04 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
-from newspipe.bootstrap import db
from datetime import datetime
+
from sqlalchemy import Index
from sqlalchemy.ext.associationproxy import association_proxy
+from newspipe.bootstrap import db
from newspipe.models.right_mixin import RightMixin
diff --git a/newspipe/models/bookmark.py b/newspipe/models/bookmark.py
index 93158bbd..ddf7924d 100644
--- a/newspipe/models/bookmark.py
+++ b/newspipe/models/bookmark.py
@@ -26,14 +26,15 @@ __revision__ = "$Date: 2016/12/07 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
-from newspipe.bootstrap import db
from datetime import datetime
+
from sqlalchemy import desc
-from sqlalchemy.orm import validates
from sqlalchemy.ext.associationproxy import association_proxy
+from sqlalchemy.orm import validates
-from newspipe.models.tag import BookmarkTag
+from newspipe.bootstrap import db
from newspipe.models.right_mixin import RightMixin
+from newspipe.models.tag import BookmarkTag
class Bookmark(db.Model, RightMixin):
diff --git a/newspipe/models/category.py b/newspipe/models/category.py
index 3abb6717..a1e1c806 100644
--- a/newspipe/models/category.py
+++ b/newspipe/models/category.py
@@ -1,8 +1,9 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
-from newspipe.bootstrap import db
from sqlalchemy import Index
+
+from newspipe.bootstrap import db
from newspipe.models.right_mixin import RightMixin
diff --git a/newspipe/models/feed.py b/newspipe/models/feed.py
index a84553bf..1521d362 100644
--- a/newspipe/models/feed.py
+++ b/newspipe/models/feed.py
@@ -26,12 +26,14 @@ __revision__ = "$Date: 2014/04/12 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
-from newspipe.bootstrap import db
from datetime import datetime
-from sqlalchemy import desc, Index
+
+from sqlalchemy import Index, desc
from sqlalchemy.orm import validates
-from newspipe.models.right_mixin import RightMixin
+
+from newspipe.bootstrap import db
from newspipe.models.article import Article
+from newspipe.models.right_mixin import RightMixin
class Feed(db.Model, RightMixin):
diff --git a/newspipe/models/user.py b/newspipe/models/user.py
index f880d3fe..179474a6 100644
--- a/newspipe/models/user.py
+++ b/newspipe/models/user.py
@@ -28,14 +28,15 @@ __license__ = "GPLv3"
import re
from datetime import datetime
-from werkzeug.security import check_password_hash
+
from flask_login import UserMixin
from sqlalchemy.orm import validates
+from werkzeug.security import check_password_hash
from newspipe.bootstrap import db
-from newspipe.models.right_mixin import RightMixin
from newspipe.models.category import Category
from newspipe.models.feed import Feed
+from newspipe.models.right_mixin import RightMixin
class User(db.Model, UserMixin, RightMixin):
diff --git a/newspipe/notifications/notifications.py b/newspipe/notifications/notifications.py
index 547ad216..2e7ec399 100644
--- a/newspipe/notifications/notifications.py
+++ b/newspipe/notifications/notifications.py
@@ -20,6 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
+
from flask import render_template
from newspipe.bootstrap import application
diff --git a/newspipe/web/decorators.py b/newspipe/web/decorators.py
index 8569a024..c68edfee 100644
--- a/newspipe/web/decorators.py
+++ b/newspipe/web/decorators.py
@@ -1,8 +1,8 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
-from threading import Thread
from functools import wraps
+from threading import Thread
from flask_login import login_required
diff --git a/newspipe/web/forms.py b/newspipe/web/forms.py
index 2efbc9a6..cb02d1e6 100644
--- a/newspipe/web/forms.py
+++ b/newspipe/web/forms.py
@@ -26,25 +26,25 @@ __revision__ = "$Date: 2015/05/06 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
-from flask import flash, url_for, redirect
-from flask_wtf import FlaskForm
+from flask import flash, redirect, url_for
from flask_babel import lazy_gettext
+from flask_wtf import FlaskForm
from werkzeug.exceptions import NotFound
from wtforms import (
- TextField,
- TextAreaField,
- PasswordField,
BooleanField,
- SubmitField,
+ HiddenField,
IntegerField,
+ PasswordField,
SelectField,
- validators,
- HiddenField,
+ SubmitField,
+ TextAreaField,
+ TextField,
+ validators
)
from wtforms.fields.html5 import EmailField, URLField
-from newspipe.lib import misc_utils
from newspipe.controllers import UserController
+from newspipe.lib import misc_utils
from newspipe.models import User
diff --git a/newspipe/web/lib/view_utils.py b/newspipe/web/lib/view_utils.py
index c6e722d3..67ffcb28 100644
--- a/newspipe/web/lib/view_utils.py
+++ b/newspipe/web/lib/view_utils.py
@@ -1,5 +1,7 @@
from functools import wraps
-from flask import request, Response, make_response
+
+from flask import Response, make_response, request
+
from newspipe.lib.utils import to_hash
diff --git a/newspipe/web/views/__init__.py b/newspipe/web/views/__init__.py
index 7d73ac8c..51214f21 100644
--- a/newspipe/web/views/__init__.py
+++ b/newspipe/web/views/__init__.py
@@ -1,9 +1,9 @@
+from newspipe.web.views import home, session_mgmt, views
+from newspipe.web.views.admin import admin_bp
from newspipe.web.views.api import v2
-from newspipe.web.views import views, home, session_mgmt
from newspipe.web.views.article import article_bp, articles_bp
+from newspipe.web.views.bookmark import bookmark_bp, bookmarks_bp
+from newspipe.web.views.category import categories_bp, category_bp
from newspipe.web.views.feed import feed_bp, feeds_bp
-from newspipe.web.views.category import category_bp, categories_bp
from newspipe.web.views.icon import icon_bp
-from newspipe.web.views.admin import admin_bp
from newspipe.web.views.user import user_bp, users_bp
-from newspipe.web.views.bookmark import bookmark_bp, bookmarks_bp
diff --git a/newspipe/web/views/admin.py b/newspipe/web/views/admin.py
index 7df683a7..f42f6938 100644
--- a/newspipe/web/views/admin.py
+++ b/newspipe/web/views/admin.py
@@ -1,12 +1,13 @@
from datetime import datetime
-from flask import Blueprint, render_template, redirect, flash, url_for
-from flask_babel import gettext, format_timedelta
-from flask_login import login_required, current_user
-from newspipe.lib.utils import redirect_url
+from flask import Blueprint, flash, redirect, render_template, url_for
+from flask_babel import format_timedelta, gettext
+from flask_login import current_user, login_required
+
from newspipe.controllers import UserController
-from newspipe.web.views.common import admin_permission
+from newspipe.lib.utils import redirect_url
from newspipe.web.forms import InformationMessageForm, UserForm
+from newspipe.web.views.common import admin_permission
admin_bp = Blueprint("admin", __name__, url_prefix="/admin")
diff --git a/newspipe/web/views/api/v2/__init__.py b/newspipe/web/views/api/v2/__init__.py
index d367da20..042b7255 100644
--- a/newspipe/web/views/api/v2/__init__.py
+++ b/newspipe/web/views/api/v2/__init__.py
@@ -1,3 +1,3 @@
-from newspipe.web.views.api.v2 import article, feed, category
+from newspipe.web.views.api.v2 import article, category, feed
__all__ = ["article", "feed", "category"]
diff --git a/newspipe/web/views/api/v2/article.py b/newspipe/web/views/api/v2/article.py
index b35d2635..638f1bd0 100644
--- a/newspipe/web/views/api/v2/article.py
+++ b/newspipe/web/views/api/v2/article.py
@@ -1,17 +1,18 @@
-from newspipe.bootstrap import application
-import dateutil.parser
from datetime import datetime
+
+import dateutil.parser
from flask import current_app
from flask_restful import Api
-from newspipe.web.views.common import api_permission
+from newspipe.bootstrap import application
from newspipe.controllers import ArticleController
from newspipe.web.views.api.v2.common import (
PyAggAbstractResource,
- PyAggResourceNew,
PyAggResourceExisting,
PyAggResourceMulti,
+ PyAggResourceNew
)
+from newspipe.web.views.common import api_permission
class ArticleNewAPI(PyAggResourceNew):
diff --git a/newspipe/web/views/api/v2/category.py b/newspipe/web/views/api/v2/category.py
index 697a283f..ab6e484a 100644
--- a/newspipe/web/views/api/v2/category.py
+++ b/newspipe/web/views/api/v2/category.py
@@ -4,9 +4,9 @@ from flask_restful import Api
from newspipe.bootstrap import application
from newspipe.controllers.category import CategoryController
from newspipe.web.views.api.v2.common import (
- PyAggResourceNew,
PyAggResourceExisting,
PyAggResourceMulti,
+ PyAggResourceNew
)
diff --git a/newspipe/web/views/api/v2/common.py b/newspipe/web/views/api/v2/common.py
index c38da8d8..5a7d7925 100644
--- a/newspipe/web/views/api/v2/common.py
+++ b/newspipe/web/views/api/v2/common.py
@@ -20,18 +20,19 @@ routes :
"""
import logging
from functools import wraps
-from werkzeug.exceptions import Unauthorized, BadRequest, Forbidden, NotFound
+
from flask import request
-from flask_restful import Resource, reqparse
from flask_login import current_user
+from flask_restful import Resource, reqparse
+from werkzeug.exceptions import BadRequest, Forbidden, NotFound, Unauthorized
+from newspipe.controllers import UserController
from newspipe.web.views.common import (
admin_permission,
api_permission,
- login_user_bundle,
jsonify,
+ login_user_bundle
)
-from newspipe.controllers import UserController
logger = logging.getLogger(__name__)
diff --git a/newspipe/web/views/api/v2/feed.py b/newspipe/web/views/api/v2/feed.py
index eaccd24a..f9e7f8c2 100644
--- a/newspipe/web/views/api/v2/feed.py
+++ b/newspipe/web/views/api/v2/feed.py
@@ -2,15 +2,18 @@ from flask import current_app
from flask_restful import Api
from newspipe.bootstrap import application
-from newspipe.web.views.common import api_permission
-from newspipe.controllers.feed import FeedController, DEFAULT_MAX_ERROR, DEFAULT_LIMIT
-
+from newspipe.controllers.feed import (
+ DEFAULT_LIMIT,
+ DEFAULT_MAX_ERROR,
+ FeedController
+)
from newspipe.web.views.api.v2.common import (
PyAggAbstractResource,
- PyAggResourceNew,
PyAggResourceExisting,
PyAggResourceMulti,
+ PyAggResourceNew
)
+from newspipe.web.views.common import api_permission
class FeedNewAPI(PyAggResourceNew):
diff --git a/newspipe/web/views/article.py b/newspipe/web/views/article.py
index 033ff039..472ff589 100644
--- a/newspipe/web/views/article.py
+++ b/newspipe/web/views/article.py
@@ -1,23 +1,26 @@
from datetime import datetime, timedelta
+
from flask import (
Blueprint,
- g,
- render_template,
- redirect,
flash,
- url_for,
+ g,
make_response,
+ redirect,
+ render_template,
request,
+ url_for
)
-
from flask_babel import gettext
-from flask_login import login_required, current_user
-
+from flask_login import current_user, login_required
from newspipe.bootstrap import db
-from newspipe.lib.utils import clear_string, redirect_url
+from newspipe.controllers import (
+ ArticleController,
+ CategoryController,
+ UserController
+)
from newspipe.lib.data import export_json
-from newspipe.controllers import ArticleController, UserController, CategoryController
+from newspipe.lib.utils import clear_string, redirect_url
from newspipe.web.lib.view_utils import etag_match
articles_bp = Blueprint("articles", __name__, url_prefix="/articles")
diff --git a/newspipe/web/views/bookmark.py b/newspipe/web/views/bookmark.py
index 8252dc2f..5d7e3d2b 100644
--- a/newspipe/web/views/bookmark.py
+++ b/newspipe/web/views/bookmark.py
@@ -27,28 +27,28 @@ __copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "AGPLv3"
import logging
-from werkzeug.exceptions import BadRequest
from flask import (
Blueprint,
- render_template,
flash,
+ make_response,
redirect,
+ render_template,
request,
- url_for,
- make_response,
+ url_for
)
from flask_babel import gettext
-from flask_login import login_required, current_user
+from flask_login import current_user, login_required
from flask_paginate import Pagination, get_page_args
from sqlalchemy import desc
+from werkzeug.exceptions import BadRequest
-from newspipe.lib.utils import redirect_url
-from newspipe.lib.data import import_pinboard_json, export_bookmarks
from newspipe.bootstrap import db
-from newspipe.web.forms import BookmarkForm
from newspipe.controllers import BookmarkController, BookmarkTagController
+from newspipe.lib.data import export_bookmarks, import_pinboard_json
+from newspipe.lib.utils import redirect_url
from newspipe.models import BookmarkTag
+from newspipe.web.forms import BookmarkForm
logger = logging.getLogger(__name__)
bookmarks_bp = Blueprint("bookmarks", __name__, url_prefix="/bookmarks")
diff --git a/newspipe/web/views/category.py b/newspipe/web/views/category.py
index 9f1a7e83..3f65e854 100644
--- a/newspipe/web/views/category.py
+++ b/newspipe/web/views/category.py
@@ -1,11 +1,15 @@
-from flask import Blueprint, render_template, flash, redirect, url_for
+from flask import Blueprint, flash, redirect, render_template, url_for
from flask_babel import gettext
-from flask_login import login_required, current_user
+from flask_login import current_user, login_required
-from newspipe.web.forms import CategoryForm
+from newspipe.controllers import (
+ ArticleController,
+ CategoryController,
+ FeedController
+)
from newspipe.lib.utils import redirect_url
+from newspipe.web.forms import CategoryForm
from newspipe.web.lib.view_utils import etag_match
-from newspipe.controllers import ArticleController, FeedController, CategoryController
categories_bp = Blueprint("categories", __name__, url_prefix="/categories")
category_bp = Blueprint("category", __name__, url_prefix="/category")
diff --git a/newspipe/web/views/common.py b/newspipe/web/views/common.py
index 8d9ecfa9..574974ce 100644
--- a/newspipe/web/views/common.py
+++ b/newspipe/web/views/common.py
@@ -1,15 +1,17 @@
import json
-from functools import wraps
from datetime import datetime
-from flask import current_app, Response
+from functools import wraps
+
+from flask import Response, current_app
from flask_login import login_user
from flask_principal import (
Identity,
Permission,
RoleNeed,
- session_identity_loader,
identity_changed,
+ session_identity_loader
)
+
from newspipe.controllers import UserController
from newspipe.lib.utils import default_handler
diff --git a/newspipe/web/views/feed.py b/newspipe/web/views/feed.py
index 16f44c86..10a86139 100644
--- a/newspipe/web/views/feed.py
+++ b/newspipe/web/views/feed.py
@@ -1,33 +1,33 @@
import logging
-import requests.exceptions
from datetime import datetime, timedelta
-from sqlalchemy import desc
-from werkzeug.exceptions import BadRequest
+import requests.exceptions
from flask import (
Blueprint,
- render_template,
flash,
+ make_response,
redirect,
+ render_template,
request,
- url_for,
- make_response,
+ url_for
)
from flask_babel import gettext
-from flask_login import login_required, current_user
+from flask_login import current_user, login_required
from flask_paginate import Pagination, get_page_args
+from sqlalchemy import desc
+from werkzeug.exceptions import BadRequest
from newspipe.bootstrap import application
-from newspipe.lib import misc_utils, utils
-from newspipe.lib.feed_utils import construct_feed_from
-from newspipe.web.lib.view_utils import etag_match
-from newspipe.web.forms import AddFeedForm
from newspipe.controllers import (
- UserController,
+ ArticleController,
CategoryController,
FeedController,
- ArticleController,
+ UserController
)
+from newspipe.lib import misc_utils, utils
+from newspipe.lib.feed_utils import construct_feed_from
+from newspipe.web.forms import AddFeedForm
+from newspipe.web.lib.view_utils import etag_match
logger = logging.getLogger(__name__)
feeds_bp = Blueprint("feeds", __name__, url_prefix="/feeds")
diff --git a/newspipe/web/views/home.py b/newspipe/web/views/home.py
index 0fe09b17..1699f106 100644
--- a/newspipe/web/views/home.py
+++ b/newspipe/web/views/home.py
@@ -1,20 +1,30 @@
-import pytz
import logging
from datetime import datetime
-from flask import current_app, render_template, request, flash, url_for, redirect
-from flask_login import login_required, current_user
-from flask_babel import gettext, get_locale
+import pytz
from babel.dates import format_datetime, format_timedelta
+from flask import (
+ current_app,
+ flash,
+ redirect,
+ render_template,
+ request,
+ url_for
+)
+from flask_babel import get_locale, gettext
+from flask_login import current_user, login_required
from newspipe.bootstrap import application
-from newspipe.lib.utils import redirect_url
+from newspipe.controllers import (
+ ArticleController,
+ CategoryController,
+ FeedController
+)
from newspipe.lib import misc_utils
+from newspipe.lib.utils import redirect_url
from newspipe.web.lib.view_utils import etag_match
from newspipe.web.views.common import jsonify
-from newspipe.controllers import FeedController, ArticleController, CategoryController
-
localize = pytz.utc.localize
logger = logging.getLogger(__name__)
diff --git a/newspipe/web/views/icon.py b/newspipe/web/views/icon.py
index 4cdcd4b0..bbb98ea5 100644
--- a/newspipe/web/views/icon.py
+++ b/newspipe/web/views/icon.py
@@ -1,4 +1,5 @@
import base64
+
from flask import Blueprint, Response, request
from newspipe.controllers import IconController
diff --git a/newspipe/web/views/session_mgmt.py b/newspipe/web/views/session_mgmt.py
index 9588e98e..801834ec 100644
--- a/newspipe/web/views/session_mgmt.py
+++ b/newspipe/web/views/session_mgmt.py
@@ -1,33 +1,33 @@
import logging
-
from datetime import datetime
-from werkzeug.security import generate_password_hash
-from werkzeug.exceptions import NotFound
+
from flask import (
- render_template,
+ current_app,
flash,
- session,
- request,
- url_for,
redirect,
- current_app,
+ render_template,
+ request,
+ session,
+ url_for
)
from flask_babel import gettext, lazy_gettext
-from flask_login import LoginManager, logout_user, login_required, current_user
+from flask_login import LoginManager, current_user, login_required, logout_user
from flask_principal import (
- Principal,
AnonymousIdentity,
+ Principal,
UserNeed,
identity_changed,
identity_loaded,
- session_identity_loader,
+ session_identity_loader
)
+from werkzeug.exceptions import NotFound
+from werkzeug.security import generate_password_hash
from newspipe.bootstrap import application
-from newspipe.web.views.common import admin_role, api_role, login_user_bundle
from newspipe.controllers import UserController
-from newspipe.web.forms import SignupForm, SigninForm
from newspipe.notifications import notifications
+from newspipe.web.forms import SigninForm, SignupForm
+from newspipe.web.views.common import admin_role, api_role, login_user_bundle
Principal(current_app)
# Create a permission with a single Need, in this case a RoleNeed.
diff --git a/newspipe/web/views/user.py b/newspipe/web/views/user.py
index b4900559..5addf80d 100644
--- a/newspipe/web/views/user.py
+++ b/newspipe/web/views/user.py
@@ -1,22 +1,29 @@
-from flask import Blueprint, g, render_template, redirect, flash, url_for, request
+from flask import (
+ Blueprint,
+ flash,
+ g,
+ redirect,
+ render_template,
+ request,
+ url_for
+)
from flask_babel import gettext
-from flask_login import login_required, current_user
+from flask_login import current_user, login_required
from flask_paginate import Pagination, get_page_args
from newspipe.bootstrap import application
-from newspipe.notifications import notifications
-from newspipe.lib import misc_utils
-from newspipe.lib.data import import_opml, import_json
-from newspipe.web.lib.user_utils import confirm_token
from newspipe.controllers import (
- UserController,
- FeedController,
ArticleController,
- CategoryController,
BookmarkController,
+ CategoryController,
+ FeedController,
+ UserController
)
-
+from newspipe.lib import misc_utils
+from newspipe.lib.data import import_json, import_opml
+from newspipe.notifications import notifications
from newspipe.web.forms import ProfileForm
+from newspipe.web.lib.user_utils import confirm_token
users_bp = Blueprint("users", __name__, url_prefix="/users")
user_bp = Blueprint("user", __name__, url_prefix="/user")
diff --git a/newspipe/web/views/views.py b/newspipe/web/views/views.py
index 346954e1..a19c7dc5 100644
--- a/newspipe/web/views/views.py
+++ b/newspipe/web/views/views.py
@@ -1,14 +1,22 @@
-import sys
import logging
import operator
+import sys
from datetime import datetime, timedelta
-from flask import request, render_template, flash, url_for, redirect, current_app
+
+from flask import (
+ current_app,
+ flash,
+ redirect,
+ render_template,
+ request,
+ url_for
+)
from flask_babel import gettext
from sqlalchemy import desc
from newspipe.bootstrap import application
-from newspipe.web import __version__
from newspipe.controllers import FeedController, UserController
+from newspipe.web import __version__
from newspipe.web.lib.view_utils import etag_match
logger = logging.getLogger(__name__)
bgstack15