aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.pre-commit-config.yaml29
-rw-r--r--COPYING2
-rw-r--r--migrations/README2
-rw-r--r--migrations/env.py7
-rw-r--r--migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py3
-rw-r--r--migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py6
-rw-r--r--migrations/versions/19bdaa6208e_add_icon_column.py3
-rw-r--r--migrations/versions/1b750a389c22_remove_email_notification_column.py3
-rw-r--r--migrations/versions/2472eddbf44b_update_of_the_user_model.py3
-rw-r--r--migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py3
-rw-r--r--migrations/versions/2c5cc05216fa_adding_tag_handling_capacities.py3
-rw-r--r--migrations/versions/3f83bfe93fc_add_updated_date_column_to_article_table.py3
-rw-r--r--migrations/versions/422da2d0234_adding_filters_field.py3
-rw-r--r--migrations/versions/48f561c0ce6_add_column_entry_id.py3
-rw-r--r--migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py3
-rw-r--r--migrations/versions/661199d8768a_problem_with_the_last_upgrade.py3
-rw-r--r--migrations/versions/8bf5694c0b9e_add_column_automatic_crawling_to_the_.py3
-rw-r--r--migrations/versions/957d4c5b8ac9_add_column_is_public_profile_to_the_.py3
-rw-r--r--migrations/versions/ac35c979311a_removed_activation_key_from_the_user_.py3
-rw-r--r--migrations/versions/b329a1a7366f_add_new_tables_for_the_bookmarks_and_.py6
-rw-r--r--migrations/versions/bdd38bd755cb_remove_email_attribute_from_users_.py3
-rw-r--r--migrations/versions/be2b8b6f33dd_add_column_private_to_the_feeds_table.py3
-rw-r--r--migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py6
-rw-r--r--migrations/versions/f700c4237e9d_remove_refresh_rate_column_from_the_.py3
-rw-r--r--migrations/versions/fa10b0bdd045_add_bio_column_to_user_table.py3
-rw-r--r--newspipe/bootstrap.py11
-rwxr-xr-xnewspipe/commands.py21
-rw-r--r--newspipe/controllers/__init__.py2
-rw-r--r--newspipe/controllers/abstract.py10
-rw-r--r--newspipe/controllers/article.py6
-rw-r--r--newspipe/controllers/bookmark.py3
-rw-r--r--newspipe/controllers/category.py3
-rw-r--r--newspipe/controllers/feed.py11
-rw-r--r--newspipe/controllers/icon.py3
-rw-r--r--newspipe/controllers/tag.py3
-rw-r--r--newspipe/controllers/user.py6
-rw-r--r--newspipe/crawler/default_crawler.py49
-rw-r--r--newspipe/lib/article_utils.py16
-rw-r--r--newspipe/lib/data.py2
-rw-r--r--newspipe/lib/feed_utils.py7
-rwxr-xr-xnewspipe/lib/misc_utils.py10
-rw-r--r--newspipe/lib/utils.py3
-rw-r--r--newspipe/models/__init__.py2
-rw-r--r--newspipe/models/article.py2
-rw-r--r--newspipe/models/bookmark.py2
-rw-r--r--newspipe/models/category.py2
-rw-r--r--newspipe/models/feed.py2
-rw-r--r--newspipe/models/icon.py2
-rw-r--r--newspipe/models/right_mixin.py6
-rw-r--r--newspipe/models/role.py2
-rw-r--r--newspipe/models/tag.py5
-rw-r--r--newspipe/models/user.py2
-rw-r--r--newspipe/notifications/emails.py5
-rw-r--r--newspipe/notifications/notifications.py3
-rw-r--r--newspipe/static/js/articles.js10
-rw-r--r--newspipe/templates/management.html2
-rw-r--r--newspipe/translations/messages.pot1
-rw-r--r--newspipe/web/decorators.py2
-rw-r--r--newspipe/web/forms.py6
-rw-r--r--newspipe/web/lib/view_utils.py4
-rw-r--r--newspipe/web/views/__init__.py20
-rw-r--r--newspipe/web/views/admin.py15
-rw-r--r--newspipe/web/views/api/v2/__init__.py4
-rw-r--r--newspipe/web/views/api/v2/article.py10
-rw-r--r--newspipe/web/views/api/v2/category.py8
-rw-r--r--newspipe/web/views/api/v2/common.py20
-rw-r--r--newspipe/web/views/api/v2/feed.py14
-rw-r--r--newspipe/web/views/article.py30
-rw-r--r--newspipe/web/views/bookmark.py2
-rw-r--r--newspipe/web/views/category.py13
-rw-r--r--newspipe/web/views/common.py15
-rw-r--r--newspipe/web/views/feed.py46
-rw-r--r--newspipe/web/views/home.py41
-rw-r--r--newspipe/web/views/icon.py4
-rw-r--r--newspipe/web/views/session_mgmt.py44
-rw-r--r--newspipe/web/views/stats.py9
-rw-r--r--newspipe/web/views/user.py30
-rw-r--r--newspipe/web/views/views.py22
-rwxr-xr-xrunserver.py4
79 files changed, 358 insertions, 331 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..ee595fc7
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,29 @@
+repos:
+ - repo: https://github.com/asottile/pyupgrade
+ rev: v2.31.1
+ hooks:
+ - id: pyupgrade
+ args: ["--py37-plus"]
+ - repo: https://github.com/asottile/reorder_python_imports
+ rev: v3.0.1
+ hooks:
+ - id: reorder-python-imports
+ additional_dependencies: ["setuptools>60.9"]
+ - repo: https://github.com/psf/black
+ rev: 22.3.0
+ hooks:
+ - id: black
+ - repo: https://github.com/PyCQA/flake8
+ rev: 4.0.1
+ hooks:
+ - id: flake8
+ additional_dependencies:
+ - flake8-bugbear
+ - flake8-implicit-str-concat
+ args: ["--max-line-length=105"]
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.1.0
+ hooks:
+ - id: fix-byte-order-marker
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
diff --git a/COPYING b/COPYING
index 2def0e88..dba13ed2 100644
--- a/COPYING
+++ b/COPYING
@@ -658,4 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>. \ No newline at end of file
+<http://www.gnu.org/licenses/>.
diff --git a/migrations/README b/migrations/README
index 98e4f9c4..2500aa1b 100644
--- a/migrations/README
+++ b/migrations/README
@@ -1 +1 @@
-Generic single-database configuration. \ No newline at end of file
+Generic single-database configuration.
diff --git a/migrations/env.py b/migrations/env.py
index cbfe86d4..4ac6ad53 100644
--- a/migrations/env.py
+++ b/migrations/env.py
@@ -1,13 +1,12 @@
-from __future__ import with_statement
-
from alembic import context
+from flask import current_app
+from sqlalchemy import engine_from_config
+from sqlalchemy import pool
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
-from flask import current_app
-from sqlalchemy import engine_from_config, pool
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
diff --git a/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py b/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py
index 95926d22..d5276fd5 100644
--- a/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py
+++ b/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py
@@ -5,10 +5,9 @@ Revises: 957d4c5b8ac9
Create Date: 2016-09-21 08:00:27.160357
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "16f8fc3cf0cc"
down_revision = "957d4c5b8ac9"
diff --git a/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py b/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py
index e07ff6d7..bd7ccf58 100644
--- a/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py
+++ b/migrations/versions/17dcb75f3fe_changed_the_type_of_the_column_last_.py
@@ -5,12 +5,12 @@ Revises: cde34831ea
Create Date: 2015-03-10 14:20:53.676344
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
-import sqlalchemy as sa
from datetime import datetime
+import sqlalchemy as sa
+from alembic import op
+
revision = "17dcb75f3fe"
down_revision = "cde34831ea"
diff --git a/migrations/versions/19bdaa6208e_add_icon_column.py b/migrations/versions/19bdaa6208e_add_icon_column.py
index 19d2977b..05259c4e 100644
--- a/migrations/versions/19bdaa6208e_add_icon_column.py
+++ b/migrations/versions/19bdaa6208e_add_icon_column.py
@@ -5,10 +5,9 @@ Revises: 422da2d0234
Create Date: 2015-07-03 12:09:58.596010
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "19bdaa6208e"
down_revision = "422da2d0234"
diff --git a/migrations/versions/1b750a389c22_remove_email_notification_column.py b/migrations/versions/1b750a389c22_remove_email_notification_column.py
index 60e02687..9846fc26 100644
--- a/migrations/versions/1b750a389c22_remove_email_notification_column.py
+++ b/migrations/versions/1b750a389c22_remove_email_notification_column.py
@@ -5,10 +5,9 @@ Revises: 48f561c0ce6
Create Date: 2015-02-25 23:01:07.253429
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "1b750a389c22"
down_revision = "48f561c0ce6"
diff --git a/migrations/versions/2472eddbf44b_update_of_the_user_model.py b/migrations/versions/2472eddbf44b_update_of_the_user_model.py
index cb6de571..f1362029 100644
--- a/migrations/versions/2472eddbf44b_update_of_the_user_model.py
+++ b/migrations/versions/2472eddbf44b_update_of_the_user_model.py
@@ -5,10 +5,9 @@ Revises: ac35c979311a
Create Date: 2016-03-01 22:35:03.659694
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "2472eddbf44b"
down_revision = "ac35c979311a"
diff --git a/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py b/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py
index 9212e5ab..14ab7a10 100644
--- a/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py
+++ b/migrations/versions/25ca960a207_mv_icons_from_feed_tbl_to_icon_tbl.py
@@ -5,10 +5,9 @@ Revises: 19bdaa6208e
Create Date: 2015-08-03 14:36:21.626411
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "25ca960a207"
down_revision = "19bdaa6208e"
diff --git a/migrations/versions/2c5cc05216fa_adding_tag_handling_capacities.py b/migrations/versions/2c5cc05216fa_adding_tag_handling_capacities.py
index 8d6c8ae8..4a91563d 100644
--- a/migrations/versions/2c5cc05216fa_adding_tag_handling_capacities.py
+++ b/migrations/versions/2c5cc05216fa_adding_tag_handling_capacities.py
@@ -5,10 +5,9 @@ Revises: be2b8b6f33dd
Create Date: 2016-11-08 07:41:13.923531
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "2c5cc05216fa"
down_revision = "be2b8b6f33dd"
diff --git a/migrations/versions/3f83bfe93fc_add_updated_date_column_to_article_table.py b/migrations/versions/3f83bfe93fc_add_updated_date_column_to_article_table.py
index 4e0df180..e0a7ab2b 100644
--- a/migrations/versions/3f83bfe93fc_add_updated_date_column_to_article_table.py
+++ b/migrations/versions/3f83bfe93fc_add_updated_date_column_to_article_table.py
@@ -5,10 +5,9 @@ Revises: 25ca960a207
Create Date: 2016-02-12 21:51:40.868539
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "3f83bfe93fc"
down_revision = "25ca960a207"
diff --git a/migrations/versions/422da2d0234_adding_filters_field.py b/migrations/versions/422da2d0234_adding_filters_field.py
index 084ddf09..5140e9fd 100644
--- a/migrations/versions/422da2d0234_adding_filters_field.py
+++ b/migrations/versions/422da2d0234_adding_filters_field.py
@@ -5,10 +5,9 @@ Revises: 17dcb75f3fe
Create Date: 2015-05-18 23:03:15.809549
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "422da2d0234"
down_revision = "17dcb75f3fe"
diff --git a/migrations/versions/48f561c0ce6_add_column_entry_id.py b/migrations/versions/48f561c0ce6_add_column_entry_id.py
index a233d0e5..69912b88 100644
--- a/migrations/versions/48f561c0ce6_add_column_entry_id.py
+++ b/migrations/versions/48f561c0ce6_add_column_entry_id.py
@@ -5,10 +5,9 @@ Revises:
Create Date: 2015-02-18 21:17:19.346998
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "48f561c0ce6"
down_revision = None
diff --git a/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py b/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py
index 9f98e68b..4527028d 100644
--- a/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py
+++ b/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py
@@ -5,10 +5,9 @@ Revises: f700c4237e9d
Create Date: 2016-10-06 11:02:41.356322
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "5553a6c05fa7"
down_revision = "f700c4237e9d"
diff --git a/migrations/versions/661199d8768a_problem_with_the_last_upgrade.py b/migrations/versions/661199d8768a_problem_with_the_last_upgrade.py
index 188ec46f..bc205d6b 100644
--- a/migrations/versions/661199d8768a_problem_with_the_last_upgrade.py
+++ b/migrations/versions/661199d8768a_problem_with_the_last_upgrade.py
@@ -5,10 +5,9 @@ Revises: 3f83bfe93fc
Create Date: 2016-02-13 11:33:14.183576
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "661199d8768a"
down_revision = "3f83bfe93fc"
diff --git a/migrations/versions/8bf5694c0b9e_add_column_automatic_crawling_to_the_.py b/migrations/versions/8bf5694c0b9e_add_column_automatic_crawling_to_the_.py
index 47e56e2e..cecbad0c 100644
--- a/migrations/versions/8bf5694c0b9e_add_column_automatic_crawling_to_the_.py
+++ b/migrations/versions/8bf5694c0b9e_add_column_automatic_crawling_to_the_.py
@@ -5,10 +5,9 @@ Revises: 5553a6c05fa7
Create Date: 2016-10-06 13:47:32.784711
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "8bf5694c0b9e"
down_revision = "5553a6c05fa7"
diff --git a/migrations/versions/957d4c5b8ac9_add_column_is_public_profile_to_the_.py b/migrations/versions/957d4c5b8ac9_add_column_is_public_profile_to_the_.py
index ac5c47be..609e37fa 100644
--- a/migrations/versions/957d4c5b8ac9_add_column_is_public_profile_to_the_.py
+++ b/migrations/versions/957d4c5b8ac9_add_column_is_public_profile_to_the_.py
@@ -5,10 +5,9 @@ Revises: 2472eddbf44b
Create Date: 2016-09-20 14:35:31.302555
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "957d4c5b8ac9"
down_revision = "2472eddbf44b"
diff --git a/migrations/versions/ac35c979311a_removed_activation_key_from_the_user_.py b/migrations/versions/ac35c979311a_removed_activation_key_from_the_user_.py
index ee16ab78..7be08068 100644
--- a/migrations/versions/ac35c979311a_removed_activation_key_from_the_user_.py
+++ b/migrations/versions/ac35c979311a_removed_activation_key_from_the_user_.py
@@ -5,10 +5,9 @@ Revises: 661199d8768a
Create Date: 2016-02-18 08:54:43.786641
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "ac35c979311a"
down_revision = "661199d8768a"
diff --git a/migrations/versions/b329a1a7366f_add_new_tables_for_the_bookmarks_and_.py b/migrations/versions/b329a1a7366f_add_new_tables_for_the_bookmarks_and_.py
index f783425f..8ba85040 100644
--- a/migrations/versions/b329a1a7366f_add_new_tables_for_the_bookmarks_and_.py
+++ b/migrations/versions/b329a1a7366f_add_new_tables_for_the_bookmarks_and_.py
@@ -5,12 +5,12 @@ Revises: 2c5cc05216fa
Create Date: 2017-05-23 21:42:37.636307
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
-import sqlalchemy as sa
from datetime import datetime
+import sqlalchemy as sa
+from alembic import op
+
revision = "b329a1a7366f"
down_revision = "2c5cc05216fa"
branch_labels = None
diff --git a/migrations/versions/bdd38bd755cb_remove_email_attribute_from_users_.py b/migrations/versions/bdd38bd755cb_remove_email_attribute_from_users_.py
index 1a97d271..ce5037fe 100644
--- a/migrations/versions/bdd38bd755cb_remove_email_attribute_from_users_.py
+++ b/migrations/versions/bdd38bd755cb_remove_email_attribute_from_users_.py
@@ -5,10 +5,9 @@ Revises: b329a1a7366f
Create Date: 2018-04-04 23:26:52.517804
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "bdd38bd755cb"
down_revision = "b329a1a7366f"
diff --git a/migrations/versions/be2b8b6f33dd_add_column_private_to_the_feeds_table.py b/migrations/versions/be2b8b6f33dd_add_column_private_to_the_feeds_table.py
index fa733719..158c0703 100644
--- a/migrations/versions/be2b8b6f33dd_add_column_private_to_the_feeds_table.py
+++ b/migrations/versions/be2b8b6f33dd_add_column_private_to_the_feeds_table.py
@@ -5,10 +5,9 @@ Revises: fa10b0bdd045
Create Date: 2016-10-24 13:28:55.964803
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "be2b8b6f33dd"
down_revision = "fa10b0bdd045"
diff --git a/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py b/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py
index 0c6ada9c..c8acfc14 100644
--- a/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py
+++ b/migrations/versions/cde34831ea_adding_feed_and_user_attributes_for_.py
@@ -5,12 +5,12 @@ Revises: 1b750a389c22
Create Date: 2015-03-04 22:59:44.665979
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
-import sqlalchemy as sa
from datetime import datetime
+import sqlalchemy as sa
+from alembic import op
+
revision = "cde34831ea"
down_revision = "1b750a389c22"
diff --git a/migrations/versions/f700c4237e9d_remove_refresh_rate_column_from_the_.py b/migrations/versions/f700c4237e9d_remove_refresh_rate_column_from_the_.py
index 626d0f1a..54ee4fd4 100644
--- a/migrations/versions/f700c4237e9d_remove_refresh_rate_column_from_the_.py
+++ b/migrations/versions/f700c4237e9d_remove_refresh_rate_column_from_the_.py
@@ -5,10 +5,9 @@ Revises: 16f8fc3cf0cc
Create Date: 2016-10-05 08:47:51.384069
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "f700c4237e9d"
down_revision = "16f8fc3cf0cc"
diff --git a/migrations/versions/fa10b0bdd045_add_bio_column_to_user_table.py b/migrations/versions/fa10b0bdd045_add_bio_column_to_user_table.py
index b94527cf..79b687b3 100644
--- a/migrations/versions/fa10b0bdd045_add_bio_column_to_user_table.py
+++ b/migrations/versions/fa10b0bdd045_add_bio_column_to_user_table.py
@@ -5,10 +5,9 @@ Revises: 8bf5694c0b9e
Create Date: 2016-10-07 10:43:04.428178
"""
-
# revision identifiers, used by Alembic.
-from alembic import op
import sqlalchemy as sa
+from alembic import op
revision = "fa10b0bdd045"
down_revision = "8bf5694c0b9e"
diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py
index 9ca81d95..0017d245 100644
--- a/newspipe/bootstrap.py
+++ b/newspipe/bootstrap.py
@@ -1,17 +1,16 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -
-
# required imports and code execution for basic functionning
-
import calendar
import logging
import os
-from flask import Flask, request
+from flask import Flask
+from flask import request
+from flask_babel import Babel
+from flask_babel import format_datetime
from flask_migrate import Migrate
-from flask_talisman import Talisman
-from flask_babel import Babel, format_datetime
from flask_sqlalchemy import SQLAlchemy
+from flask_talisman import Talisman
def set_logging(
diff --git a/newspipe/commands.py b/newspipe/commands.py
index c7d7b71a..2d6aae5e 100755
--- a/newspipe/commands.py
+++ b/newspipe/commands.py
@@ -1,16 +1,17 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
import logging
-from dateutil.relativedelta import relativedelta
-from datetime import datetime, date
+from datetime import date
+from datetime import datetime
import click
+from dateutil.relativedelta import relativedelta
from werkzeug.security import generate_password_hash
import newspipe.models
-from newspipe.bootstrap import application, db
-from newspipe.controllers import UserController, ArticleController
+from newspipe.bootstrap import application
+from newspipe.bootstrap import db
+from newspipe.controllers import ArticleController
+from newspipe.controllers import UserController
logger = logging.getLogger("commands")
@@ -57,7 +58,7 @@ def delete_user(user_id=None):
"Delete the user with the id specified in the command line."
try:
user = UserController().delete(user_id)
- print("User {} deleted".format(user.nickname))
+ print(f"User {user.nickname} deleted")
except Exception as e:
print(e)
@@ -73,7 +74,7 @@ def delete_inactive_users(last_seen):
for user in users:
db.session.delete(user)
try:
- print("Deleting user {}...".format(user.nickname))
+ print(f"Deleting user {user.nickname}...")
db.session.commit()
except Exception:
db.session.rollback()
@@ -93,7 +94,7 @@ def disable_inactive_users(last_seen):
user.is_public_profile = False
user.automatic_crawling = False
try:
- print("Updating user {}...".format(user.nickname))
+ print(f"Updating user {user.nickname}...")
db.session.commit()
except Exception:
db.session.rollback()
@@ -164,4 +165,4 @@ def fetch_asyncio(user_id=None, feed_id=None):
loop.run_until_complete(asyncio.gather(producer_coro, consumer_coro))
end = datetime.now()
loop.close()
- logger.info("Crawler finished in {} seconds.".format((end - start).seconds))
+ logger.info(f"Crawler finished in {(end - start).seconds} seconds.")
diff --git a/newspipe/controllers/__init__.py b/newspipe/controllers/__init__.py
index 9b193cc5..6769aa32 100644
--- a/newspipe/controllers/__init__.py
+++ b/newspipe/controllers/__init__.py
@@ -1,5 +1,5 @@
from .feed import FeedController
-from .category import CategoryController
+from .category import CategoryController # noreorder
from .article import ArticleController
from .user import UserController
from .icon import IconController
diff --git a/newspipe/controllers/abstract.py b/newspipe/controllers/abstract.py
index 0d422d43..ed60f78b 100644
--- a/newspipe/controllers/abstract.py
+++ b/newspipe/controllers/abstract.py
@@ -3,8 +3,10 @@ from collections import defaultdict
from datetime import datetime
import dateutil.parser
-from sqlalchemy import func, or_
-from werkzeug.exceptions import Forbidden, NotFound
+from sqlalchemy import func
+from sqlalchemy import or_
+from werkzeug.exceptions import Forbidden
+from werkzeug.exceptions import NotFound
from newspipe.bootstrap import db
@@ -89,7 +91,7 @@ class AbstractController:
)
if not obj:
raise NotFound(
- {"message": "No %r (%r)" % (self._db_cls.__class__.__name__, filters)}
+ {"message": f"No {self._db_cls.__class__.__name__!r} ({filters!r})"}
)
return obj
@@ -160,7 +162,7 @@ class AbstractController:
assert right in {"read", "write"}, (
"right must be 'read' or 'write' with role %r" % role
)
- columns = getattr(cls._db_cls, "fields_%s_%s" % (role, right))()
+ columns = getattr(cls._db_cls, f"fields_{role}_{right}")()
for column in columns:
result[column] = {}
db_col = getattr(cls._db_cls, column).property.columns[0]
diff --git a/newspipe/controllers/article.py b/newspipe/controllers/article.py
index bbb83b62..4b8f63ff 100644
--- a/newspipe/controllers/article.py
+++ b/newspipe/controllers/article.py
@@ -4,13 +4,13 @@ from collections import Counter
import sqlalchemy
from sqlalchemy import func
+from .abstract import AbstractController
from newspipe.bootstrap import db
-from newspipe.controllers import CategoryController, FeedController
+from newspipe.controllers import CategoryController
+from newspipe.controllers import 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 08c8256f..81412a5e 100644
--- a/newspipe/controllers/bookmark.py
+++ b/newspipe/controllers/bookmark.py
@@ -1,9 +1,8 @@
import logging
-from newspipe.models import Bookmark
-
from .abstract import AbstractController
from .tag import BookmarkTagController
+from newspipe.models import Bookmark
logger = logging.getLogger(__name__)
diff --git a/newspipe/controllers/category.py b/newspipe/controllers/category.py
index dc140a7b..25869c6a 100644
--- a/newspipe/controllers/category.py
+++ b/newspipe/controllers/category.py
@@ -1,7 +1,6 @@
-from newspipe.models import Category
-
from .abstract import AbstractController
from .feed import FeedController
+from newspipe.models import Category
class CategoryController(AbstractController):
diff --git a/newspipe/controllers/feed.py b/newspipe/controllers/feed.py
index 18f29906..9461a798 100644
--- a/newspipe/controllers/feed.py
+++ b/newspipe/controllers/feed.py
@@ -1,13 +1,14 @@
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 datetime import datetime
+from datetime import timedelta
from .abstract import AbstractController
from .icon import IconController
+from newspipe.bootstrap import application
+from newspipe.lib.utils import clear_string
+from newspipe.models import Feed
+from newspipe.models import User
logger = logging.getLogger(__name__)
DEFAULT_LIMIT = 5
diff --git a/newspipe/controllers/icon.py b/newspipe/controllers/icon.py
index b0fad5ac..91ecc60c 100644
--- a/newspipe/controllers/icon.py
+++ b/newspipe/controllers/icon.py
@@ -2,11 +2,10 @@ import base64
import requests
+from .abstract import AbstractController
from newspipe.lib.utils import newspipe_get
from newspipe.models import Icon
-from .abstract import AbstractController
-
class IconController(AbstractController):
_db_cls = Icon
diff --git a/newspipe/controllers/tag.py b/newspipe/controllers/tag.py
index a0bd1afd..a2531e35 100644
--- a/newspipe/controllers/tag.py
+++ b/newspipe/controllers/tag.py
@@ -1,8 +1,7 @@
import logging
-from newspipe.models.tag import BookmarkTag
-
from .abstract import AbstractController
+from newspipe.models.tag import BookmarkTag
logger = logging.getLogger(__name__)
diff --git a/newspipe/controllers/user.py b/newspipe/controllers/user.py
index 76908a73..64dac06c 100644
--- a/newspipe/controllers/user.py
+++ b/newspipe/controllers/user.py
@@ -1,10 +1,10 @@
import logging
-from werkzeug.security import check_password_hash, generate_password_hash
-
-from newspipe.models import User
+from werkzeug.security import check_password_hash
+from werkzeug.security import generate_password_hash
from .abstract import AbstractController
+from newspipe.models import User
logger = logging.getLogger(__name__)
diff --git a/newspipe/crawler/default_crawler.py b/newspipe/crawler/default_crawler.py
index 7c8ce21e..440c5088 100644
--- a/newspipe/crawler/default_crawler.py
+++ b/newspipe/crawler/default_crawler.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@@ -59,29 +57,30 @@ async def parse_feed(user, feed):
resp = None
# with (await sem):
try:
- logger.info("Retrieving feed {}".format(feed.link))
+ logger.info(f"Retrieving feed {feed.link}")
resp = newspipe_get(feed.link, timeout=5)
except Exception:
- logger.info("Problem when reading feed {}".format(feed.link))
+ logger.info(f"Problem when reading feed {feed.link}")
+ return
+
+ if None is resp:
return
- finally:
- if None is resp:
- return
+
+ try:
+ content = io.BytesIO(resp.content)
+ parsed_feed = feedparser.parse(content)
+ except Exception as e:
+ up_feed["last_error"] = str(e)
+ up_feed["error_count"] = feed.error_count + 1
+ logger.exception("error when parsing feed: " + str(e))
+
+ up_feed["last_retrieved"] = datetime.now(dateutil.tz.tzlocal())
+ if parsed_feed is None:
try:
- content = io.BytesIO(resp.content)
- parsed_feed = feedparser.parse(content)
+ FeedController().update({"id": feed.id}, up_feed)
except Exception as e:
- up_feed["last_error"] = str(e)
- up_feed["error_count"] = feed.error_count + 1
- logger.exception("error when parsing feed: " + str(e))
- finally:
- up_feed["last_retrieved"] = datetime.now(dateutil.tz.tzlocal())
- if parsed_feed is None:
- try:
- FeedController().update({"id": feed.id}, up_feed)
- except Exception as e:
- logger.exception("something bad here: " + str(e))
- return
+ logger.exception("something bad here: " + str(e))
+ return
if not is_parsing_ok(parsed_feed):
up_feed["last_error"] = str(parsed_feed["bozo_exception"])
@@ -98,14 +97,14 @@ async def parse_feed(user, feed):
try:
up_feed.update(construct_feed_from(feed.link, parsed_feed))
except Exception:
- logger.exception("error when constructing feed: {}".format(feed.link))
+ logger.exception(f"error when constructing feed: {feed.link}")
if feed.title and "title" in up_feed:
# do not override the title set by the user
del up_feed["title"]
try:
FeedController().update({"id": feed.id}, up_feed)
except Exception:
- logger.exception("error when updating feed: {}".format(feed.link))
+ logger.exception(f"error when updating feed: {feed.link}")
return articles
@@ -129,7 +128,7 @@ async def insert_articles(queue, nḅ_producers=1):
logger.info("None")
articles = []
- logger.info("Inserting articles for {}".format(feed.link))
+ logger.info(f"Inserting articles for {feed.link}")
art_contr = ArticleController(user.id)
for article in articles:
@@ -160,7 +159,7 @@ async def retrieve_feed(queue, users, feed_id=None):
Launch the processus.
"""
for user in users:
- logger.info("Starting to retrieve feeds for {}".format(user.nickname))
+ logger.info(f"Starting to retrieve feeds for {user.nickname}")
filters = {}
filters["user_id"] = user.id
if feed_id is not None:
@@ -187,7 +186,7 @@ async def retrieve_feed(queue, users, feed_id=None):
feeds.append(feed)
if feeds == []:
- logger.info("No feed to retrieve for {}".format(user.nickname))
+ logger.info(f"No feed to retrieve for {user.nickname}")
for feed in feeds:
articles = await parse_feed(user, feed)
diff --git a/newspipe/lib/article_utils.py b/newspipe/lib/article_utils.py
index bc046835..876591a4 100644
--- a/newspipe/lib/article_utils.py
+++ b/newspipe/lib/article_utils.py
@@ -1,13 +1,17 @@
import html
import logging
import re
-from datetime import datetime, timezone
-from dateutil.parser._parser import ParserError
+from datetime import datetime
+from datetime import timezone
from enum import Enum
-from urllib.parse import SplitResult, urlsplit, urlunsplit
+from urllib.parse import SplitResult
+from urllib.parse import urlsplit
+from urllib.parse import urlunsplit
import dateutil.parser
-from bs4 import BeautifulSoup, SoupStrainer
+from bs4 import BeautifulSoup
+from bs4 import SoupStrainer
+from dateutil.parser._parser import ParserError
from requests.exceptions import MissingSchema
from newspipe.bootstrap import application
@@ -49,9 +53,7 @@ async def construct_article(entry, feed, fields=None, fetch=True):
timezone.utc
)
except ParserError:
- logger.exception(
- "Error when parsing date: {}".format(entry[date_key])
- )
+ logger.exception(f"Error when parsing date: {entry[date_key]}")
except Exception:
pass
else:
diff --git a/newspipe/lib/data.py b/newspipe/lib/data.py
index 0093c226..dbb9fc42 100644
--- a/newspipe/lib/data.py
+++ b/newspipe/lib/data.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/lib/feed_utils.py b/newspipe/lib/feed_utils.py
index 47a32b43..15b3076c 100644
--- a/newspipe/lib/feed_utils.py
+++ b/newspipe/lib/feed_utils.py
@@ -4,10 +4,13 @@ import urllib
import feedparser
import requests
-from bs4 import BeautifulSoup, SoupStrainer
+from bs4 import BeautifulSoup
+from bs4 import SoupStrainer
from newspipe.bootstrap import application
-from newspipe.lib.utils import rebuild_url, try_get_icon_url, try_keys
+from newspipe.lib.utils import rebuild_url
+from newspipe.lib.utils import try_get_icon_url
+from newspipe.lib.utils import try_keys
logger = logging.getLogger(__name__)
logging.captureWarnings(True)
diff --git a/newspipe/lib/misc_utils.py b/newspipe/lib/misc_utils.py
index 785b62db..1d8d40dc 100755
--- a/newspipe/lib/misc_utils.py
+++ b/newspipe/lib/misc_utils.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@@ -52,7 +50,7 @@ except Exception:
logger = logging.getLogger(__name__)
-ALLOWED_EXTENSIONS = set(["xml", "opml", "json"])
+ALLOWED_EXTENSIONS = {"xml", "opml", "json"}
def is_safe_url(target):
@@ -86,7 +84,7 @@ def allowed_file(filename):
def opened_w_error(filename, mode="r"):
try:
f = open(filename, mode)
- except IOError as err:
+ except OSError as err:
yield None, err
else:
try:
@@ -139,7 +137,7 @@ def clean_url(url):
"""
parsed_url = urlparse(url)
qd = parse_qs(parsed_url.query, keep_blank_values=True)
- filtered = dict((k, v) for k, v in qd.items() if not k.startswith("utm_"))
+ filtered = {k: v for k, v in qd.items() if not k.startswith("utm_")}
return urlunparse(
[
parsed_url.scheme,
@@ -192,7 +190,7 @@ def tag_cloud(tags):
Generates a tags cloud.
"""
tags.sort(key=operator.itemgetter(0))
- max_tag = max([tag[1] for tag in tags])
+ max_tag = max(tag[1] for tag in tags)
return "\n".join(
[
("<font size=%d>%s</font>" % (min(1 + count * 7 / max_tag, 7), word))
diff --git a/newspipe/lib/utils.py b/newspipe/lib/utils.py
index beef75ac..e839d99c 100644
--- a/newspipe/lib/utils.py
+++ b/newspipe/lib/utils.py
@@ -5,7 +5,8 @@ import urllib
from hashlib import md5
import requests
-from flask import request, url_for
+from flask import request
+from flask import url_for
from newspipe.bootstrap import application
diff --git a/newspipe/models/__init__.py b/newspipe/models/__init__.py
index 329c7e61..8389f6ef 100644
--- a/newspipe/models/__init__.py
+++ b/newspipe/models/__init__.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/models/article.py b/newspipe/models/article.py
index 3289f674..8d0bf5d1 100644
--- a/newspipe/models/article.py
+++ b/newspipe/models/article.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/models/bookmark.py b/newspipe/models/bookmark.py
index 54c14536..d6be3862 100644
--- a/newspipe/models/bookmark.py
+++ b/newspipe/models/bookmark.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/models/category.py b/newspipe/models/category.py
index a1e1c806..93267300 100644
--- a/newspipe/models/category.py
+++ b/newspipe/models/category.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
from sqlalchemy import Index
from newspipe.bootstrap import db
diff --git a/newspipe/models/feed.py b/newspipe/models/feed.py
index 557bc7aa..f29153d0 100644
--- a/newspipe/models/feed.py
+++ b/newspipe/models/feed.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/models/icon.py b/newspipe/models/icon.py
index 99c10224..837ff4ad 100644
--- a/newspipe/models/icon.py
+++ b/newspipe/models/icon.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
from newspipe.bootstrap import db
diff --git a/newspipe/models/right_mixin.py b/newspipe/models/right_mixin.py
index 670beafa..a9468079 100644
--- a/newspipe/models/right_mixin.py
+++ b/newspipe/models/right_mixin.py
@@ -8,15 +8,15 @@ class RightMixin:
@staticmethod
def _fields_base_read():
- return set(["id"])
+ return {"id"}
@staticmethod
def _fields_api_write():
- return set([])
+ return set()
@staticmethod
def _fields_api_read():
- return set(["id"])
+ return {"id"}
@classmethod
def fields_base_write(cls):
diff --git a/newspipe/models/role.py b/newspipe/models/role.py
index f8c2a53d..7262bd48 100644
--- a/newspipe/models/role.py
+++ b/newspipe/models/role.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/models/tag.py b/newspipe/models/tag.py
index 0c961830..1fc039c1 100644
--- a/newspipe/models/tag.py
+++ b/newspipe/models/tag.py
@@ -1,7 +1,6 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-from sqlalchemy import Index, ForeignKeyConstraint
+from sqlalchemy import ForeignKeyConstraint
+from sqlalchemy import Index
from newspipe.bootstrap import db
diff --git a/newspipe/models/user.py b/newspipe/models/user.py
index 158da03e..347f97d9 100644
--- a/newspipe/models/user.py
+++ b/newspipe/models/user.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py
index a2a3827d..7f4ecffd 100644
--- a/newspipe/notifications/emails.py
+++ b/newspipe/notifications/emails.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@@ -18,12 +16,11 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
import logging
import smtplib
+from email import charset
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
-from email import charset
from newspipe.bootstrap import application
from newspipe.web.decorators import async_maker
diff --git a/newspipe/notifications/notifications.py b/newspipe/notifications/notifications.py
index 10eb85a5..2c4db222 100644
--- a/newspipe/notifications/notifications.py
+++ b/newspipe/notifications/notifications.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@@ -18,7 +16,6 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
import datetime
from flask import render_template
diff --git a/newspipe/static/js/articles.js b/newspipe/static/js/articles.js
index 36291362..4a6e8e73 100644
--- a/newspipe/static/js/articles.js
+++ b/newspipe/static/js/articles.js
@@ -27,7 +27,7 @@ function change_unread_counter(feed_id, increment) {
var new_value = parseInt(el.textContent) + increment;
document.getElementById("unread-"+feed_id).textContent = new_value;
}
-
+
document.getElementById("total-unread").textContent = parseInt(document.getElementById("total-unread").textContent) + increment;
if (new_value == 0) {
@@ -87,7 +87,7 @@ Array.prototype.map.call(nodes, function(node) {
// sends the updates to the server
fetch(API_ROOT + "article/" + article_id, {
- method: "PUT",
+ method: "PUT",
headers: {
'Content-Type': 'application/json',
},
@@ -121,7 +121,7 @@ Array.prototype.map.call(nodes, function(node) {
// sends the updates to the server
fetch(API_ROOT + "article/" + article_id, {
- method: "PUT",
+ method: "PUT",
headers: {
'Content-Type': 'application/json',
},
@@ -158,7 +158,7 @@ Array.prototype.map.call(nodes, function(node) {
// sends the updates to the server
fetch(API_ROOT + "article/" + article_id, {
- method: "PUT",
+ method: "PUT",
headers: {
'Content-Type': 'application/json',
},
@@ -190,7 +190,7 @@ Array.prototype.map.call(nodes, function(node) {
// sends the updates to the server
fetch(API_ROOT + "articles", {
- method: "DELETE",
+ method: "DELETE",
headers: {
'Content-Type': 'application/json',
},
diff --git a/newspipe/templates/management.html b/newspipe/templates/management.html
index 19173a2b..4e977f84 100644
--- a/newspipe/templates/management.html
+++ b/newspipe/templates/management.html
@@ -78,7 +78,7 @@
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" name="includeprivate" checked />
- <label class="form-check-label">Include private feeds</label>
+ <label class="form-check-label">Include private feeds</label>
</div>
</div>
<button class="btn btn-primary" type="submit">{{ _('Export') }}</button>
diff --git a/newspipe/translations/messages.pot b/newspipe/translations/messages.pot
index 01ac39ef..94c233fa 100644
--- a/newspipe/translations/messages.pot
+++ b/newspipe/translations/messages.pot
@@ -1096,4 +1096,3 @@ msgstr ""
#: newspipe/web/views/views.py:30
msgid "Forbidden."
msgstr ""
-
diff --git a/newspipe/web/decorators.py b/newspipe/web/decorators.py
index c68edfee..b7dacdda 100644
--- a/newspipe/web/decorators.py
+++ b/newspipe/web/decorators.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
from functools import wraps
from threading import Thread
diff --git a/newspipe/web/forms.py b/newspipe/web/forms.py
index 7dd21161..39d38878 100644
--- a/newspipe/web/forms.py
+++ b/newspipe/web/forms.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@@ -171,7 +169,7 @@ class UserForm(FlaskForm):
submit = SubmitField(lazy_gettext("Save"))
def validate(self):
- validated = super(UserForm, self).validate()
+ validated = super().validate()
if self.nickname.data != User.make_valid_nickname(self.nickname.data):
self.nickname.errors.append(
lazy_gettext(
@@ -202,7 +200,7 @@ class ProfileForm(FlaskForm):
submit = SubmitField(lazy_gettext("Save"))
def validate(self):
- validated = super(ProfileForm, self).validate()
+ validated = super().validate()
if self.password.data:
if self.password.data != self.password_conf.data:
message = lazy_gettext("Passwords aren't the same.")
diff --git a/newspipe/web/lib/view_utils.py b/newspipe/web/lib/view_utils.py
index 67ffcb28..91757bba 100644
--- a/newspipe/web/lib/view_utils.py
+++ b/newspipe/web/lib/view_utils.py
@@ -1,6 +1,8 @@
from functools import wraps
-from flask import Response, make_response, request
+from flask import make_response
+from flask import request
+from flask import Response
from newspipe.lib.utils import to_hash
diff --git a/newspipe/web/views/__init__.py b/newspipe/web/views/__init__.py
index bfd25e4e..cdaf2cc3 100644
--- a/newspipe/web/views/__init__.py
+++ b/newspipe/web/views/__init__.py
@@ -1,13 +1,19 @@
-from newspipe.web.views import home, session_mgmt, views
+from newspipe.web.views import home
+from newspipe.web.views import session_mgmt
+from newspipe.web.views import views
from newspipe.web.views.admin import admin_bp
from newspipe.web.views.api import v2
-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.article import article_bp
+from newspipe.web.views.article import articles_bp
+from newspipe.web.views.bookmark import bookmark_bp
+from newspipe.web.views.bookmark import bookmarks_bp
+from newspipe.web.views.category import categories_bp
+from newspipe.web.views.category import category_bp
+from newspipe.web.views.feed import feed_bp
+from newspipe.web.views.feed import feeds_bp
from newspipe.web.views.icon import icon_bp
-from newspipe.web.views.user import user_bp
from newspipe.web.views.stats import stats_bp
+from newspipe.web.views.user import user_bp
__all__ = [
"home",
@@ -25,5 +31,5 @@ __all__ = [
"feeds_bp",
"icon_bp",
"user_bp",
- "stats_bp"
+ "stats_bp",
]
diff --git a/newspipe/web/views/admin.py b/newspipe/web/views/admin.py
index 2cddd4c6..b35a3f96 100644
--- a/newspipe/web/views/admin.py
+++ b/newspipe/web/views/admin.py
@@ -1,11 +1,18 @@
from datetime import datetime
-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 flask import Blueprint
+from flask import flash
+from flask import redirect
+from flask import render_template
+from flask import url_for
+from flask_babel import format_timedelta
+from flask_babel import gettext
+from flask_login import current_user
+from flask_login import login_required
from newspipe.controllers import UserController
-from newspipe.web.forms import InformationMessageForm, UserForm
+from newspipe.web.forms import InformationMessageForm
+from newspipe.web.forms import 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 042b7255..3f9f9df4 100644
--- a/newspipe/web/views/api/v2/__init__.py
+++ b/newspipe/web/views/api/v2/__init__.py
@@ -1,3 +1,5 @@
-from newspipe.web.views.api.v2 import article, category, feed
+from newspipe.web.views.api.v2 import article
+from newspipe.web.views.api.v2 import category
+from newspipe.web.views.api.v2 import feed
__all__ = ["article", "feed", "category"]
diff --git a/newspipe/web/views/api/v2/article.py b/newspipe/web/views/api/v2/article.py
index 92915006..09bdb4e4 100644
--- a/newspipe/web/views/api/v2/article.py
+++ b/newspipe/web/views/api/v2/article.py
@@ -6,12 +6,10 @@ from flask_restful import Api
from newspipe.bootstrap import application
from newspipe.controllers import ArticleController
-from newspipe.web.views.api.v2.common import (
- PyAggAbstractResource,
- PyAggResourceExisting,
- PyAggResourceMulti,
- PyAggResourceNew,
-)
+from newspipe.web.views.api.v2.common import PyAggAbstractResource
+from newspipe.web.views.api.v2.common import PyAggResourceExisting
+from newspipe.web.views.api.v2.common import PyAggResourceMulti
+from newspipe.web.views.api.v2.common import PyAggResourceNew
from newspipe.web.views.common import api_permission
diff --git a/newspipe/web/views/api/v2/category.py b/newspipe/web/views/api/v2/category.py
index 84397991..615fea2d 100644
--- a/newspipe/web/views/api/v2/category.py
+++ b/newspipe/web/views/api/v2/category.py
@@ -3,11 +3,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 (
- PyAggResourceExisting,
- PyAggResourceMulti,
- PyAggResourceNew,
-)
+from newspipe.web.views.api.v2.common import PyAggResourceExisting
+from newspipe.web.views.api.v2.common import PyAggResourceMulti
+from newspipe.web.views.api.v2.common import PyAggResourceNew
class CategoryNewAPI(PyAggResourceNew):
diff --git a/newspipe/web/views/api/v2/common.py b/newspipe/web/views/api/v2/common.py
index 36817118..72e562fa 100644
--- a/newspipe/web/views/api/v2/common.py
+++ b/newspipe/web/views/api/v2/common.py
@@ -23,16 +23,18 @@ from functools import wraps
from flask import request
from flask_login import current_user
-from flask_restful import Resource, reqparse
-from werkzeug.exceptions import BadRequest, Forbidden, NotFound, Unauthorized
+from flask_restful import reqparse
+from flask_restful import Resource
+from werkzeug.exceptions import BadRequest
+from werkzeug.exceptions import Forbidden
+from werkzeug.exceptions import NotFound
+from werkzeug.exceptions import Unauthorized
from newspipe.controllers import UserController
-from newspipe.web.views.common import (
- admin_permission,
- api_permission,
- jsonify,
- login_user_bundle,
-)
+from newspipe.web.views.common import admin_permission
+from newspipe.web.views.common import api_permission
+from newspipe.web.views.common import jsonify
+from newspipe.web.views.common import login_user_bundle
logger = logging.getLogger(__name__)
@@ -102,7 +104,7 @@ class PyAggAbstractResource(Resource):
attrs = self.controller_cls._get_attrs_desc("base", right)
assert attrs, "No defined attrs for %s" % self.__class__.__name__
- for attr_name, attr in attrs.items():
+ for attr_name, _attr in attrs.items():
if not default and attr_name not in in_values:
continue
else:
diff --git a/newspipe/web/views/api/v2/feed.py b/newspipe/web/views/api/v2/feed.py
index 01791a8d..89f174d1 100644
--- a/newspipe/web/views/api/v2/feed.py
+++ b/newspipe/web/views/api/v2/feed.py
@@ -2,13 +2,13 @@ from flask import current_app
from flask_restful import Api
from newspipe.bootstrap import application
-from newspipe.controllers.feed import DEFAULT_LIMIT, DEFAULT_MAX_ERROR, FeedController
-from newspipe.web.views.api.v2.common import (
- PyAggAbstractResource,
- PyAggResourceExisting,
- PyAggResourceMulti,
- PyAggResourceNew,
-)
+from newspipe.controllers.feed import DEFAULT_LIMIT
+from newspipe.controllers.feed import DEFAULT_MAX_ERROR
+from newspipe.controllers.feed import FeedController
+from newspipe.web.views.api.v2.common import PyAggAbstractResource
+from newspipe.web.views.api.v2.common import PyAggResourceExisting
+from newspipe.web.views.api.v2.common import PyAggResourceMulti
+from newspipe.web.views.api.v2.common import PyAggResourceNew
from newspipe.web.views.common import api_permission
diff --git a/newspipe/web/views/article.py b/newspipe/web/views/article.py
index a59722e0..8d4054db 100644
--- a/newspipe/web/views/article.py
+++ b/newspipe/web/views/article.py
@@ -1,21 +1,23 @@
-from datetime import datetime, timedelta
-
-from flask import (
- Blueprint,
- flash,
- make_response,
- redirect,
- render_template,
- request,
- url_for,
-)
+from datetime import datetime
+from datetime import timedelta
+
+from flask import Blueprint
+from flask import flash
+from flask import make_response
+from flask import redirect
+from flask import render_template
+from flask import request
+from flask import url_for
from flask_babel import gettext
-from flask_login import current_user, login_required
+from flask_login import current_user
+from flask_login import login_required
from newspipe.bootstrap import db
-from newspipe.controllers import ArticleController, UserController
+from newspipe.controllers import ArticleController
+from newspipe.controllers import UserController
from newspipe.lib.data import export_json
-from newspipe.lib.utils import clear_string, redirect_url
+from newspipe.lib.utils import clear_string
+from newspipe.lib.utils import 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 de546b7d..04d2e8af 100644
--- a/newspipe/web/views/bookmark.py
+++ b/newspipe/web/views/bookmark.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
diff --git a/newspipe/web/views/category.py b/newspipe/web/views/category.py
index 392b8df6..962e5478 100644
--- a/newspipe/web/views/category.py
+++ b/newspipe/web/views/category.py
@@ -1,8 +1,15 @@
-from flask import Blueprint, flash, redirect, render_template, url_for
+from flask import Blueprint
+from flask import flash
+from flask import redirect
+from flask import render_template
+from flask import url_for
from flask_babel import gettext
-from flask_login import current_user, login_required
+from flask_login import current_user
+from flask_login import login_required
-from newspipe.controllers import ArticleController, CategoryController, FeedController
+from newspipe.controllers import ArticleController
+from newspipe.controllers import CategoryController
+from newspipe.controllers import FeedController
from newspipe.lib.utils import redirect_url
from newspipe.web.forms import CategoryForm
from newspipe.web.lib.view_utils import etag_match
diff --git a/newspipe/web/views/common.py b/newspipe/web/views/common.py
index c286888f..2ae7fdf6 100644
--- a/newspipe/web/views/common.py
+++ b/newspipe/web/views/common.py
@@ -2,15 +2,14 @@ import json
from datetime import datetime
from functools import wraps
-from flask import Response, current_app
+from flask import current_app
+from flask import Response
from flask_login import login_user
-from flask_principal import (
- Identity,
- Permission,
- RoleNeed,
- identity_changed,
- session_identity_loader,
-)
+from flask_principal import Identity
+from flask_principal import identity_changed
+from flask_principal import Permission
+from flask_principal import RoleNeed
+from flask_principal import 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 10d0b527..d14a87c5 100644
--- a/newspipe/web/views/feed.py
+++ b/newspipe/web/views/feed.py
@@ -1,29 +1,29 @@
import logging
-from datetime import datetime, timedelta
+from datetime import datetime
+from datetime import timedelta
import requests.exceptions
-from flask import (
- Blueprint,
- flash,
- make_response,
- redirect,
- render_template,
- request,
- url_for,
-)
+from flask import Blueprint
+from flask import flash
+from flask import make_response
+from flask import redirect
+from flask import render_template
+from flask import request
+from flask import url_for
from flask_babel import gettext
-from flask_login import current_user, login_required
-from flask_paginate import Pagination, get_page_args
+from flask_login import current_user
+from flask_login import login_required
+from flask_paginate import get_page_args
+from flask_paginate import Pagination
from werkzeug.exceptions import BadRequest
from newspipe.bootstrap import application
-from newspipe.controllers import (
- ArticleController,
- CategoryController,
- FeedController,
- UserController,
-)
-from newspipe.lib import misc_utils, utils
+from newspipe.controllers import ArticleController
+from newspipe.controllers import CategoryController
+from newspipe.controllers import FeedController
+from newspipe.controllers import UserController
+from newspipe.lib import misc_utils
+from newspipe.lib import 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
@@ -159,9 +159,7 @@ def bookmarklet():
try:
feed = construct_feed_from(url)
except requests.exceptions.ConnectionError:
- flash(
- gettext("Impossible to connect to the address: {}.".format(url)), "danger"
- )
+ flash(gettext(f"Impossible to connect to the address: {url}."), "danger")
return redirect(url_for("home"))
except Exception:
logger.exception("something bad happened when fetching %r", url)
@@ -285,9 +283,7 @@ def process_form(feed_id=None):
try:
feed = construct_feed_from(url)
except requests.exceptions.ConnectionError:
- flash(
- gettext("Impossible to connect to the address: {}.".format(url)), "danger"
- )
+ flash(gettext(f"Impossible to connect to the address: {url}."), "danger")
return redirect(url_for("home"))
except Exception:
logger.exception("something bad happened when fetching %r", url)
diff --git a/newspipe/web/views/home.py b/newspipe/web/views/home.py
index e7ee603c..8a3ee0a0 100644
--- a/newspipe/web/views/home.py
+++ b/newspipe/web/views/home.py
@@ -2,13 +2,23 @@ import logging
from datetime import datetime
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 babel.dates import format_datetime
+from babel.dates import format_timedelta
+from flask import current_app
+from flask import flash
+from flask import redirect
+from flask import render_template
+from flask import request
+from flask import url_for
+from flask_babel import get_locale
+from flask_babel import gettext
+from flask_login import current_user
+from flask_login import login_required
from newspipe.bootstrap import application
-from newspipe.controllers import ArticleController, CategoryController, FeedController
+from newspipe.controllers import ArticleController
+from newspipe.controllers import CategoryController
+from newspipe.controllers import FeedController
from newspipe.lib import misc_utils
from newspipe.lib.utils import redirect_url
from newspipe.web.lib.view_utils import etag_match
@@ -75,14 +85,17 @@ def home():
search_title=search_title,
search_content=search_content,
):
- return "?filter_=%s&limit=%s&feed=%d&liked=%s&query=%s&search_title=%s&search_content=%s" % (
- filter_,
- limit,
- feed,
- 1 if liked else 0,
- query,
- search_title,
- search_content,
+ return (
+ "?filter_=%s&limit=%s&feed=%d&liked=%s&query=%s&search_title=%s&search_content=%s"
+ % (
+ filter_,
+ limit,
+ feed,
+ 1 if liked else 0,
+ query,
+ search_title,
+ search_content,
+ )
)
return render_template(
@@ -207,7 +220,7 @@ def fetch(feed_id=None):
flash(
gettext(
"The manual retrieving of news is only available "
- + "for administrator, on the Heroku platform."
+ "for administrator, on the Heroku platform."
),
"info",
)
diff --git a/newspipe/web/views/icon.py b/newspipe/web/views/icon.py
index 99535c04..f34e654e 100644
--- a/newspipe/web/views/icon.py
+++ b/newspipe/web/views/icon.py
@@ -1,6 +1,8 @@
import base64
-from flask import Blueprint, Response, request
+from flask import Blueprint
+from flask import request
+from flask import Response
from newspipe.controllers import IconController
from newspipe.web.lib.view_utils import etag_match
diff --git a/newspipe/web/views/session_mgmt.py b/newspipe/web/views/session_mgmt.py
index 8aa1cf60..6aad5833 100644
--- a/newspipe/web/views/session_mgmt.py
+++ b/newspipe/web/views/session_mgmt.py
@@ -1,32 +1,34 @@
import logging
from datetime import datetime
-from werkzeug.exceptions import NotFound
-from flask import (
- current_app,
- flash,
- redirect,
- render_template,
- session,
- url_for,
-)
+from flask import current_app
+from flask import flash
+from flask import redirect
+from flask import render_template
+from flask import session
+from flask import url_for
from flask_babel import gettext
-from flask_login import LoginManager, current_user, login_required, logout_user
-from flask_principal import (
- AnonymousIdentity,
- Principal,
- UserNeed,
- identity_changed,
- identity_loaded,
- session_identity_loader,
-)
+from flask_login import current_user
+from flask_login import login_required
+from flask_login import LoginManager
+from flask_login import logout_user
+from flask_principal import AnonymousIdentity
+from flask_principal import identity_changed
+from flask_principal import identity_loaded
+from flask_principal import Principal
+from flask_principal import session_identity_loader
+from flask_principal import UserNeed
+from werkzeug.exceptions import NotFound
from werkzeug.security import generate_password_hash
from newspipe.bootstrap import application
from newspipe.controllers import UserController
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
+from newspipe.web.forms import SigninForm
+from newspipe.web.forms import SignupForm
+from newspipe.web.views.common import admin_role
+from newspipe.web.views.common import api_role
+from newspipe.web.views.common import login_user_bundle
Principal(current_app)
# Create a permission with a single Need, in this case a RoleNeed.
@@ -128,7 +130,7 @@ def signup():
return redirect(url_for("home"))
flash(
- gettext("Your account has been created. " "Check your mail to confirm it."),
+ gettext("Your account has been created. Check your mail to confirm it."),
"success",
)
diff --git a/newspipe/web/views/stats.py b/newspipe/web/views/stats.py
index d890524c..cf53925a 100644
--- a/newspipe/web/views/stats.py
+++ b/newspipe/web/views/stats.py
@@ -1,10 +1,9 @@
+from flask import Blueprint
+from flask import jsonify
+from flask_login import current_user
+from flask_login import login_required
-from flask import (
- Blueprint,
- jsonify
-)
from newspipe.controllers import ArticleController
-from flask_login import current_user, login_required
stats_bp = Blueprint("stats", __name__, url_prefix="/stats")
diff --git a/newspipe/web/views/user.py b/newspipe/web/views/user.py
index c20777e7..b8d01967 100644
--- a/newspipe/web/views/user.py
+++ b/newspipe/web/views/user.py
@@ -1,18 +1,24 @@
-from flask import Blueprint, flash, redirect, render_template, request, url_for
+from flask import Blueprint
+from flask import flash
+from flask import redirect
+from flask import render_template
+from flask import request
+from flask import url_for
from flask_babel import gettext
-from flask_login import current_user, login_required
-from flask_paginate import Pagination, get_page_args
+from flask_login import current_user
+from flask_login import login_required
+from flask_paginate import get_page_args
+from flask_paginate import Pagination
from newspipe.bootstrap import application
-from newspipe.controllers import (
- ArticleController,
- BookmarkController,
- CategoryController,
- FeedController,
- UserController,
-)
+from newspipe.controllers import ArticleController
+from newspipe.controllers import BookmarkController
+from newspipe.controllers import CategoryController
+from newspipe.controllers import FeedController
+from newspipe.controllers import UserController
from newspipe.lib import misc_utils
-from newspipe.lib.data import import_json, import_opml
+from newspipe.lib.data import import_json
+from newspipe.lib.data import import_opml
from newspipe.web.forms import ProfileForm
from newspipe.web.lib.user_utils import confirm_token
@@ -174,7 +180,7 @@ def profile():
except Exception as error:
flash(
gettext(
- "Problem while updating your profile: " "%(error)s", error=error
+ "Problem while updating your profile: %(error)s", error=error
),
"danger",
)
diff --git a/newspipe/web/views/views.py b/newspipe/web/views/views.py
index d896c97b..02f4cad8 100644
--- a/newspipe/web/views/views.py
+++ b/newspipe/web/views/views.py
@@ -1,14 +1,22 @@
import logging
import operator
import sys
-from datetime import datetime, timedelta
-
-from flask import current_app, flash, redirect, render_template, request, url_for
+from datetime import datetime
+from datetime import timedelta
+
+from flask import current_app
+from flask import flash
+from flask import redirect
+from flask import render_template
+from flask import request
+from flask import url_for
from flask_babel import gettext
from sqlalchemy import desc
-from newspipe.bootstrap import application, talisman
-from newspipe.controllers import FeedController, UserController
+from newspipe.bootstrap import application
+from newspipe.bootstrap import talisman
+from newspipe.controllers import FeedController
+from newspipe.controllers import UserController
from newspipe.web import __version__
from newspipe.web.lib.view_utils import etag_match
@@ -89,9 +97,9 @@ def about_more():
version = __version__.split("-")
if len(version) == 1:
newspipe_version = version[0]
- version_url = "https://git.sr.ht/~cedric/newspipe/refs/{}".format(version[0])
+ version_url = f"https://git.sr.ht/~cedric/newspipe/refs/{version[0]}"
else:
- newspipe_version = "{} - {}".format(version[0], version[2][1:])
+ newspipe_version = f"{version[0]} - {version[2][1:]}"
version_url = "https://git.sr.ht/~cedric/newspipe/commit/{}".format(
version[2][1:]
)
diff --git a/runserver.py b/runserver.py
index 32e5e8e7..8da3ec1e 100755
--- a/runserver.py
+++ b/runserver.py
@@ -1,6 +1,4 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
# Newspipe - A web news aggregator.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@@ -21,8 +19,8 @@
from flask import g
from flask_restful import Api
-from newspipe.bootstrap import application
from newspipe import commands
+from newspipe.bootstrap import application
def register_commands(app):
bgstack15