diff options
Diffstat (limited to 'python/fatcat_web')
-rw-r--r-- | python/fatcat_web/__init__.py | 15 | ||||
-rw-r--r-- | python/fatcat_web/auth.py | 13 | ||||
-rw-r--r-- | python/fatcat_web/cors.py | 3 | ||||
-rw-r--r-- | python/fatcat_web/graphics.py | 3 | ||||
-rw-r--r-- | python/fatcat_web/search.py | 7 | ||||
-rw-r--r-- | python/fatcat_web/web_config.py | 3 |
6 files changed, 25 insertions, 19 deletions
diff --git a/python/fatcat_web/__init__.py b/python/fatcat_web/__init__.py index 3207bc75..336b4133 100644 --- a/python/fatcat_web/__init__.py +++ b/python/fatcat_web/__init__.py @@ -1,23 +1,22 @@ import sys +import elasticsearch +import fatcat_openapi_client +from authlib.flask.client import OAuth from flask import Flask from flask.logging import create_logger -from flask_uuid import FlaskUUID from flask_debugtoolbar import DebugToolbarExtension from flask_login import LoginManager -from flask_wtf.csrf import CSRFProtect from flask_misaka import Misaka from flask_mwoauth import MWOAuth -from authlib.flask.client import OAuth -from loginpass import create_flask_blueprint, Gitlab, GitHub, ORCiD +from flask_uuid import FlaskUUID +from flask_wtf.csrf import CSRFProtect +from loginpass import GitHub, Gitlab, ORCiD, create_flask_blueprint from raven.contrib.flask import Sentry -import fatcat_openapi_client -import elasticsearch from fatcat_web.web_config import Config - toolbar = DebugToolbarExtension() app = Flask(__name__, static_url_path='/static') app.config.from_object(Config) @@ -76,7 +75,7 @@ app.register_blueprint(mwoauth.bp, url_prefix='/auth/wikipedia') app.es_client = elasticsearch.Elasticsearch(Config.ELASTICSEARCH_BACKEND) -from fatcat_web import routes, editing_routes, ref_routes, auth, cors, forms +from fatcat_web import auth, cors, editing_routes, forms, ref_routes, routes # TODO: blocking on ORCID support in loginpass if Config.ORCID_CLIENT_ID: diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py index 73869544..137bc2bb 100644 --- a/python/fatcat_web/auth.py +++ b/python/fatcat_web/auth.py @@ -1,11 +1,14 @@ from collections import namedtuple -import requests -import pymacaroons -from flask import render_template, abort, redirect, session, flash -from flask_login import logout_user, login_user, UserMixin -from fatcat_web import login_manager, app, api, priv_api, Config + import fatcat_openapi_client +import pymacaroons +import requests +from flask import abort, flash, redirect, render_template, session +from flask_login import UserMixin, login_user, logout_user + +from fatcat_web import Config, api, app, login_manager, priv_api + def handle_logout(): logout_user() diff --git a/python/fatcat_web/cors.py b/python/fatcat_web/cors.py index d84babd8..cb2054b2 100644 --- a/python/fatcat_web/cors.py +++ b/python/fatcat_web/cors.py @@ -6,7 +6,8 @@ This snippet from: http://flask.pocoo.org/snippets/56/ from datetime import timedelta from functools import update_wrapper -from flask import make_response, request, current_app + +from flask import current_app, make_response, request def crossdomain(origin=None, methods=None, headers=None, diff --git a/python/fatcat_web/graphics.py b/python/fatcat_web/graphics.py index 0765a777..b5a83f6c 100644 --- a/python/fatcat_web/graphics.py +++ b/python/fatcat_web/graphics.py @@ -1,9 +1,10 @@ -from typing import List, Tuple, Dict +from typing import Dict, List, Tuple import pygal from pygal.style import CleanStyle + def ia_coverage_histogram(rows: List[Tuple]) -> pygal.Graph: """ Note: this returns a raw pygal chart; it does not render it to SVG/PNG diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index 95f1f5c9..73781016 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -4,17 +4,18 @@ Helpers for doing elasticsearch queries (used in the web interface; not part of the formal API) """ -import sys import datetime +import sys from dataclasses import dataclass -from typing import List, Optional, Any +from typing import Any, List, Optional import elasticsearch -from elasticsearch_dsl import Search, Q import elasticsearch_dsl.response +from elasticsearch_dsl import Q, Search from fatcat_web import app + class FatcatSearchError(Exception): def __init__(self, status_code: int, name: str, description: str = None): diff --git a/python/fatcat_web/web_config.py b/python/fatcat_web/web_config.py index b0a50e0f..c15fefa4 100644 --- a/python/fatcat_web/web_config.py +++ b/python/fatcat_web/web_config.py @@ -10,9 +10,10 @@ import scripts. """ import os -import raven import subprocess +import raven + basedir = os.path.abspath(os.path.dirname(__file__)) class Config(object): |