From 2db481989a0108349d50d7dbefe35829d8bae7a4 Mon Sep 17 00:00:00 2001 From: crunk Date: Wed, 24 Apr 2024 23:05:36 +0200 Subject: [PATCH] changed autoformatter --- setup.py | 4 ++-- verse/adminpage.py | 7 +++---- verse/admintool.py | 5 ++--- verse/app.py | 1 - verse/deploydb.py | 3 +-- verse/distribusiselector.py | 9 ++++----- verse/distribusisinfo.py | 1 - verse/distribusiworkflow.py | 14 +++++++------- verse/editor.py | 11 +++++------ verse/forms/uploadform.py | 4 +--- verse/migrations/env.py | 23 ++++++++++++----------- verse/models/usermodel.py | 3 +-- verse/start.py | 11 +++++------ verse/statuspengguna/forgotpassword.py | 7 +++---- verse/statuspengguna/helper.py | 9 ++++----- verse/statuspengguna/loginuser.py | 1 - verse/statuspengguna/registeruser.py | 7 +++---- verse/statuspengguna/resetpassword.py | 7 +++---- verse/themeselector.py | 3 +-- verse/upload.py | 9 ++++----- verse/uploadpage.py | 5 ++--- 21 files changed, 63 insertions(+), 81 deletions(-) diff --git a/setup.py b/setup.py index 340f994..ce7462a 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,3 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup -setup(name='library', version='1.0', packages=find_packages()) +setup(name="library", version="1.0", packages=find_packages()) diff --git a/verse/adminpage.py b/verse/adminpage.py index 9c35dc1..c12fac3 100644 --- a/verse/adminpage.py +++ b/verse/adminpage.py @@ -1,16 +1,15 @@ import os import shutil -from flask import render_template -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) - from app import db from distribusisinfo import DistribusisInfo +from flask import render_template from forms.admindistribusiform import AdminDistribusiForm from forms.adminuserform import AdminUserForm from models.distribusimodel import Distribusis from models.usermodel import User +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) def AdminPage(): diff --git a/verse/admintool.py b/verse/admintool.py index 21aa782..8fc9e2e 100644 --- a/verse/admintool.py +++ b/verse/admintool.py @@ -1,11 +1,10 @@ import sys -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) - from app import create_app, db from models.distribusimodel import Distribusis # noqa: F401 from models.usermodel import User # noqa: F401 +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) def admintool(): diff --git a/verse/app.py b/verse/app.py index 438e982..2e6a698 100644 --- a/verse/app.py +++ b/verse/app.py @@ -59,7 +59,6 @@ def settings(): return APP - def settings_from_file(): settings = {} if os.path.isfile("settings_development.toml"): diff --git a/verse/deploydb.py b/verse/deploydb.py index 26c2e5b..6ebd4eb 100644 --- a/verse/deploydb.py +++ b/verse/deploydb.py @@ -1,8 +1,7 @@ def deploy(): """Run deployment of database.""" - from flask_migrate import init, migrate, stamp, upgrade - from app import create_app, db + from flask_migrate import init, migrate, stamp, upgrade from models.distribusimodel import Distribusis # noqa: F401 # This model is required for flask_migrate to make the table from models.usermodel import User # noqa: F401 diff --git a/verse/distribusiselector.py b/verse/distribusiselector.py index 60203b2..3a5d72f 100644 --- a/verse/distribusiselector.py +++ b/verse/distribusiselector.py @@ -1,13 +1,10 @@ import os import shutil -from flask import flash, render_template -from flask_login import current_user -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) - from app import db from distribusisinfo import DistribusisInfo +from flask import flash, render_template +from flask_login import current_user from forms.distribusiform import DistribusiForm from forms.publicthemeform import PublicThemeForm from forms.selectorform import SelectorForm @@ -15,6 +12,8 @@ from forms.themeform import ThemeForm from forms.uploadform import UploadForm from models.distribusimodel import Distribusis from models.usermodel import User +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) # UserPengguna from statuspengguna.helper import UserHelper diff --git a/verse/distribusisinfo.py b/verse/distribusisinfo.py index 5a47d5f..0b40c1b 100644 --- a/verse/distribusisinfo.py +++ b/verse/distribusisinfo.py @@ -1,5 +1,4 @@ from flask_login import current_user - from models.distribusimodel import Distribusis from models.usermodel import User diff --git a/verse/distribusiworkflow.py b/verse/distribusiworkflow.py index 9546ac8..b4ce328 100644 --- a/verse/distribusiworkflow.py +++ b/verse/distribusiworkflow.py @@ -2,17 +2,13 @@ import os import shutil import zipfile +from app import db # Tada! from distribusi.cli import build_argparser -from distribusi.distribusi import distribusify -from flask import flash, redirect, render_template, url_for -from flask_login import current_user -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) - -from app import db from distribusiselector import SelectorVisible from distribusisinfo import DistribusisInfo +from flask import flash, redirect, render_template, url_for +from flask_login import current_user from forms.distribusiform import DistribusiForm from forms.publicthemeform import PublicThemeForm from forms.selectorform import SelectorForm @@ -21,9 +17,13 @@ from forms.themeform import ThemeForm from forms.uploadform import UploadForm from models.distribusimodel import Distribusis from models.usermodel import User +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) # UserPengguna from statuspengguna.helper import UserHelper +from distribusi.distribusi import distribusify + def DistribusiWorkflow(): distribusiform = DistribusiForm() diff --git a/verse/editor.py b/verse/editor.py index 6966d7d..bfbfaeb 100644 --- a/verse/editor.py +++ b/verse/editor.py @@ -2,14 +2,10 @@ import os import shutil import bleach -from bleach_allowlist import all_styles -from flask import render_template -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) -from werkzeug.utils import secure_filename - from app import db +from bleach_allowlist import all_styles from distribusisinfo import DistribusisInfo +from flask import render_template from forms.distribusiform import DistribusiForm from forms.editorform import EditorForm from forms.publicthemeform import PublicThemeForm @@ -17,7 +13,10 @@ from forms.selectorform import SelectorForm from forms.themeform import ThemeForm from forms.uploadform import UploadForm from models.distribusimodel import Distribusis +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) from statuspengguna.helper import UserHelper +from werkzeug.utils import secure_filename def Editor(): diff --git a/verse/forms/uploadform.py b/verse/forms/uploadform.py index 3d47e72..4087463 100644 --- a/verse/forms/uploadform.py +++ b/verse/forms/uploadform.py @@ -1,3 +1,4 @@ +from app import settings from flask_wtf import FlaskForm from flask_wtf.file import FileAllowed, FileField, FileRequired, FileSize from wtforms import (IntegerField, SelectField, StringField, SubmitField, @@ -5,8 +6,6 @@ from wtforms import (IntegerField, SelectField, StringField, SubmitField, from wtforms.validators import (DataRequired, Length, NumberRange, ValidationError) -from app import settings - class UploadForm(FlaskForm): """File upload class for a new site in distribusi-verse""" @@ -33,7 +32,6 @@ class UploadForm(FlaskForm): year_choices.append((str(year), str(year))) return year_choices - sitename = StringField( "Name of your archive section:", validators=[ diff --git a/verse/migrations/env.py b/verse/migrations/env.py index 68feded..847c719 100644 --- a/verse/migrations/env.py +++ b/verse/migrations/env.py @@ -3,9 +3,8 @@ from __future__ import with_statement import logging from logging.config import fileConfig -from flask import current_app - from alembic import context +from flask import current_app # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -14,17 +13,19 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) -logger = logging.getLogger('alembic.env') +logger = logging.getLogger("alembic.env") # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata config.set_main_option( - 'sqlalchemy.url', - str(current_app.extensions['migrate'].db.get_engine().url).replace( - '%', '%%')) -target_metadata = current_app.extensions['migrate'].db.metadata + "sqlalchemy.url", + str(current_app.extensions["migrate"].db.get_engine().url).replace( + "%", "%%" + ), +) +target_metadata = current_app.extensions["migrate"].db.metadata # other values from the config, defined by the needs of env.py, # can be acquired: @@ -65,20 +66,20 @@ def run_migrations_online(): # when there are no changes to the schema # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html def process_revision_directives(context, revision, directives): - if getattr(config.cmd_opts, 'autogenerate', False): + if getattr(config.cmd_opts, "autogenerate", False): script = directives[0] if script.upgrade_ops.is_empty(): directives[:] = [] - logger.info('No changes in schema detected.') + logger.info("No changes in schema detected.") - connectable = current_app.extensions['migrate'].db.get_engine() + connectable = current_app.extensions["migrate"].db.get_engine() with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata, process_revision_directives=process_revision_directives, - **current_app.extensions['migrate'].configure_args + **current_app.extensions["migrate"].configure_args, ) with context.begin_transaction(): diff --git a/verse/models/usermodel.py b/verse/models/usermodel.py index 254fe3f..43633ab 100644 --- a/verse/models/usermodel.py +++ b/verse/models/usermodel.py @@ -1,6 +1,5 @@ -from flask_login import UserMixin - from app import db +from flask_login import UserMixin class User(UserMixin, db.Model): diff --git a/verse/start.py b/verse/start.py index 80af292..b352c9b 100644 --- a/verse/start.py +++ b/verse/start.py @@ -2,12 +2,6 @@ from datetime import timedelta -from flask import (Blueprint, redirect, render_template, send_from_directory, - session, url_for) -from flask_login import current_user, login_required, logout_user -from flask_mail import Mail -from flask_wtf.csrf import CSRFError - # Interface! these are seperate files in main folder from adminpage import AdminPage from app import create_app, login_manager @@ -16,6 +10,11 @@ from distribusiselector import DistribusiSelector from distribusisinfo import DistribusisInfo from distribusiworkflow import DistribusiWorkflow from editor import Editor +from flask import (Blueprint, redirect, render_template, send_from_directory, + session, url_for) +from flask_login import current_user, login_required, logout_user +from flask_mail import Mail +from flask_wtf.csrf import CSRFError # Use upload form to populate filters from forms.uploadform import UploadForm from models.distribusimodel import Distribusis diff --git a/verse/statuspengguna/forgotpassword.py b/verse/statuspengguna/forgotpassword.py index eaeb395..546cb0a 100644 --- a/verse/statuspengguna/forgotpassword.py +++ b/verse/statuspengguna/forgotpassword.py @@ -1,14 +1,13 @@ from datetime import datetime from uuid import uuid1 +from app import db from flask import render_template from flask_mail import Message -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) - -from app import db from forms.forgotpasswordform import ForgotPasswordForm from models.usermodel import User +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) def ForgotPassword(mail): diff --git a/verse/statuspengguna/helper.py b/verse/statuspengguna/helper.py index 5daad75..1724bce 100644 --- a/verse/statuspengguna/helper.py +++ b/verse/statuspengguna/helper.py @@ -1,14 +1,13 @@ import os -from flask import flash -from flask_login import current_user -from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, - InvalidRequestError) - from app import db from distribusisinfo import DistribusisInfo +from flask import flash +from flask_login import current_user from models.distribusimodel import Distribusis from models.usermodel import User +from sqlalchemy.exc import (DatabaseError, DataError, InterfaceError, + InvalidRequestError) class UserHelper: diff --git a/verse/statuspengguna/loginuser.py b/verse/statuspengguna/loginuser.py index a7c5424..1968f56 100644 --- a/verse/statuspengguna/loginuser.py +++ b/verse/statuspengguna/loginuser.py @@ -1,7 +1,6 @@ from flask import abort, flash, redirect, render_template, request, url_for from flask_bcrypt import check_password_hash from flask_login import login_user - from forms.loginform import LoginForm from models.usermodel import User diff --git a/verse/statuspengguna/registeruser.py b/verse/statuspengguna/registeruser.py index ac8167e..4bf8da6 100644 --- a/verse/statuspengguna/registeruser.py +++ b/verse/statuspengguna/registeruser.py @@ -1,14 +1,13 @@ +from app import db from flask import flash, redirect, render_template, url_for from flask_bcrypt import generate_password_hash from flask_login import login_user +from forms.registerform import RegisterForm +from models.usermodel import User from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError, InterfaceError, InvalidRequestError) from werkzeug.routing import BuildError -from app import db -from forms.registerform import RegisterForm -from models.usermodel import User - def RegisterUser(): registerform = RegisterForm() diff --git a/verse/statuspengguna/resetpassword.py b/verse/statuspengguna/resetpassword.py index d91b2e6..57f0615 100644 --- a/verse/statuspengguna/resetpassword.py +++ b/verse/statuspengguna/resetpassword.py @@ -1,16 +1,15 @@ from datetime import datetime +from app import db from flask import flash, redirect, render_template, url_for from flask_bcrypt import generate_password_hash from flask_login import login_user +from forms.resetpasswordform import ResetPasswordForm +from models.usermodel import User from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError, InterfaceError, InvalidRequestError) from werkzeug.routing import BuildError -from app import db -from forms.resetpasswordform import ResetPasswordForm -from models.usermodel import User - def ResetPassword(path): linkvalid = False diff --git a/verse/themeselector.py b/verse/themeselector.py index 2582809..68e2e1b 100644 --- a/verse/themeselector.py +++ b/verse/themeselector.py @@ -1,9 +1,8 @@ import os import shutil -from flask import render_template - from distribusisinfo import DistribusisInfo +from flask import render_template from forms.distribusiform import DistribusiForm from forms.publicthemeform import PublicThemeForm from forms.selectorform import SelectorForm diff --git a/verse/upload.py b/verse/upload.py index 6e3a336..a332413 100644 --- a/verse/upload.py +++ b/verse/upload.py @@ -1,16 +1,15 @@ import os import shutil -from flask import flash -from flask_login import current_user -from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError, - InterfaceError, InvalidRequestError) - from app import db from distribusiselector import SelectCurrentDistribusi +from flask import flash +from flask_login import current_user from forms.uploadform import UploadForm from models.distribusimodel import Distribusis from models.usermodel import User +from sqlalchemy.exc import (DatabaseError, DataError, IntegrityError, + InterfaceError, InvalidRequestError) from statuspengguna.helper import UserHelper diff --git a/verse/uploadpage.py b/verse/uploadpage.py index dc8e9bb..8718ec2 100644 --- a/verse/uploadpage.py +++ b/verse/uploadpage.py @@ -1,14 +1,13 @@ -from flask import render_template - +from app import APP from distribusiselector import SelectorVisible from distribusisinfo import DistribusisInfo +from flask import render_template from forms.distribusiform import DistribusiForm from forms.publicthemeform import PublicThemeForm from forms.selectorform import SelectorForm from forms.themeform import ThemeForm # UserPengguna from statuspengguna.helper import UserHelper -from app import APP from upload import UploadNewDistribusi, UploadUpdatedFiles