From 0e04493a39a4153480b58b762e7273272944d452 Mon Sep 17 00:00:00 2001 From: Siddharth Sharma Date: Tue, 17 Aug 2021 22:45:21 +0530 Subject: [PATCH] removed all unused imports --- openlibrary/app.py | 1 - openlibrary/catalog/add_book/__init__.py | 1 - openlibrary/catalog/marc/marc_subject.py | 3 +-- openlibrary/code.py | 3 --- openlibrary/core/lists/model.py | 4 ---- openlibrary/core/models.py | 2 +- openlibrary/core/observations.py | 1 - openlibrary/core/processors/__init__.py | 1 - openlibrary/core/sponsorships.py | 3 +-- openlibrary/core/vendors.py | 1 - openlibrary/core/waitinglist.py | 1 - openlibrary/coverstore/archive.py | 1 - openlibrary/coverstore/code.py | 3 --- openlibrary/data/sitemap.py | 1 - openlibrary/i18n/__init__.py | 2 +- openlibrary/plugins/admin/code.py | 4 +--- openlibrary/plugins/admin/mem.py | 1 - openlibrary/plugins/books/readlinks.py | 1 - openlibrary/plugins/importapi/tests/test_code_ils.py | 1 - openlibrary/plugins/openlibrary/api.py | 6 +----- openlibrary/plugins/openlibrary/code.py | 3 --- openlibrary/plugins/openlibrary/connection.py | 2 +- openlibrary/plugins/openlibrary/design.py | 3 +-- openlibrary/plugins/openlibrary/home.py | 1 - openlibrary/plugins/openlibrary/lists.py | 1 - openlibrary/plugins/openlibrary/processors.py | 1 - openlibrary/plugins/openlibrary/stats.py | 1 - openlibrary/plugins/openlibrary/tests/test_home.py | 5 ----- openlibrary/plugins/openlibrary/tests/test_listapi.py | 2 -- openlibrary/plugins/openlibrary/tests/test_ratingsapi.py | 3 --- openlibrary/plugins/openlibrary/utils.py | 1 - openlibrary/plugins/upstream/account.py | 8 ++------ openlibrary/plugins/upstream/addbook.py | 4 ---- openlibrary/plugins/upstream/code.py | 4 +--- openlibrary/plugins/upstream/covers.py | 1 - openlibrary/plugins/upstream/data.py | 1 - openlibrary/plugins/upstream/jsdef.py | 2 +- openlibrary/plugins/upstream/models.py | 5 +---- openlibrary/plugins/upstream/tests/test_borrow.py | 2 -- openlibrary/plugins/upstream/utils.py | 4 ++-- openlibrary/plugins/worksearch/languages.py | 5 ++--- openlibrary/plugins/worksearch/publishers.py | 5 ++--- openlibrary/plugins/worksearch/subjects.py | 3 +-- openlibrary/plugins/worksearch/tests/test_worksearch.py | 3 +-- openlibrary/records/__init__.py | 2 -- openlibrary/records/functions.py | 3 --- openlibrary/records/matchers.py | 2 -- openlibrary/solr/data_provider.py | 3 --- openlibrary/solr/db_load_works.py | 1 - openlibrary/solr/update_work.py | 6 +----- scripts/2009/01/dumps/jsondump.py | 1 - scripts/2009/10/loadmemcache.py | 1 - scripts/2009/10/loadworks.py | 2 -- scripts/2009/12/fix_no_index.py | 4 ++-- scripts/2011/02/fix_redirects.py | 1 - scripts/2011/05/account_v2_migration.py | 2 -- scripts/ipstats.py | 1 - scripts/lc_marc_update.py | 1 - scripts/legacy/solr_author_merge_work_finder.py | 1 - scripts/manage-imports.py | 1 - scripts/minicron.py | 1 - scripts/new-solr-updater.py | 1 - scripts/oldump.py | 1 - scripts/pull-templates.py | 1 - scripts/store_counts.py | 1 - 65 files changed, 24 insertions(+), 124 deletions(-) diff --git a/openlibrary/app.py b/openlibrary/app.py index 55d80175be5..b0de9569498 100644 --- a/openlibrary/app.py +++ b/openlibrary/app.py @@ -21,7 +21,6 @@ def GET(self, name): # In infogami, the class with this functionality is called page. # We are redefining with a slightly different terminology to make # things more readable. - pass # view is just a base class. # Defining a class extending from _app.page auto-registers it inside infogami. diff --git a/openlibrary/catalog/add_book/__init__.py b/openlibrary/catalog/add_book/__init__.py index 0f7067182cd..1dcb43110ea 100644 --- a/openlibrary/catalog/add_book/__init__.py +++ b/openlibrary/catalog/add_book/__init__.py @@ -22,7 +22,6 @@ response = load(record) """ -import json import re import unicodedata as ucd diff --git a/openlibrary/catalog/marc/marc_subject.py b/openlibrary/catalog/marc/marc_subject.py index c1350474788..1628e786f45 100644 --- a/openlibrary/catalog/marc/marc_subject.py +++ b/openlibrary/catalog/marc/marc_subject.py @@ -15,8 +15,7 @@ from openlibrary.catalog.get_ia import get_from_archive, marc_formats, urlopen_keep_trying from openlibrary.catalog.marc import get_subjects from openlibrary.catalog.marc.marc_binary import MarcBinary -from openlibrary.catalog.marc.marc_xml import read_marc_file, MarcXml, BlankTag, BadSubtag -from openlibrary.catalog.utils import remove_trailing_dot, remove_trailing_number_dot, flip_name +from openlibrary.catalog.marc.marc_xml import MarcXml subject_fields = set(['600', '610', '611', '630', '648', '650', '651', '662']) diff --git a/openlibrary/code.py b/openlibrary/code.py index 7d5bece1e24..941022c853a 100644 --- a/openlibrary/code.py +++ b/openlibrary/code.py @@ -33,7 +33,6 @@ def setup(): load_views() # load actions - from . import actions logger.info("loading complete.") @@ -51,7 +50,5 @@ def setup_logging(): def load_views(): """Registers all views by loading all view modules. """ - from .views import showmarc - from .views import loanstats setup() diff --git a/openlibrary/core/lists/model.py b/openlibrary/core/lists/model.py index 30e5f2bbdd7..90dc9d8d901 100644 --- a/openlibrary/core/lists/model.py +++ b/openlibrary/core/lists/model.py @@ -6,9 +6,6 @@ import web import logging -from infogami import config -from infogami.infobase import client, common -from infogami.utils import stats from openlibrary.core import helpers as h from openlibrary.core import cache @@ -16,7 +13,6 @@ from openlibrary.plugins.worksearch.search import get_solr import six -from six.moves import urllib logger = logging.getLogger("openlibrary.lists.model") diff --git a/openlibrary/core/models.py b/openlibrary/core/models.py index 301f0d3b523..55db736b19f 100644 --- a/openlibrary/core/models.py +++ b/openlibrary/core/models.py @@ -20,7 +20,7 @@ from openlibrary.core.vendors import create_edition_from_amazon_metadata # Seed might look unused, but removing it causes an error :/ -from openlibrary.core.lists.model import ListMixin, Seed +from openlibrary.core.lists.model import ListMixin from . import cache, waitinglist from six.moves import urllib diff --git a/openlibrary/core/observations.py b/openlibrary/core/observations.py index b65cc30f391..04653b62776 100644 --- a/openlibrary/core/observations.py +++ b/openlibrary/core/observations.py @@ -4,7 +4,6 @@ from infogami import config from infogami.utils.view import public -from openlibrary import accounts from openlibrary.utils import extract_numeric_id_from_olid from . import cache diff --git a/openlibrary/core/processors/__init__.py b/openlibrary/core/processors/__init__.py index 01fd63f75c2..e69de29bb2d 100644 --- a/openlibrary/core/processors/__init__.py +++ b/openlibrary/core/processors/__init__.py @@ -1 +0,0 @@ -from openlibrary.core.processors.readableurls import ReadableUrlProcessor diff --git a/openlibrary/core/sponsorships.py b/openlibrary/core/sponsorships.py index ef50c47b4ca..b8d5a0daf96 100644 --- a/openlibrary/core/sponsorships.py +++ b/openlibrary/core/sponsorships.py @@ -3,7 +3,6 @@ import requests import web -from six.moves.urllib.parse import urlencode from collections import OrderedDict from infogami.utils.view import public @@ -12,7 +11,7 @@ get_betterworldbooks_metadata, get_amazon_metadata) from openlibrary import accounts -from openlibrary.accounts.model import get_internet_archive_id, sendmail +from openlibrary.accounts.model import get_internet_archive_id from openlibrary.core.civicrm import ( get_contact_id_by_username, get_sponsorships_by_contact_id, diff --git a/openlibrary/core/vendors.py b/openlibrary/core/vendors.py index c2b2432d7d0..d1b168cb4d7 100644 --- a/openlibrary/core/vendors.py +++ b/openlibrary/core/vendors.py @@ -249,7 +249,6 @@ def search_amazon(title='', author=''): :return: dict of "results", a list of one or more found books, with metadata. :rtype: dict """ - pass def _get_amazon_metadata(id_, id_type='isbn', resources=None): diff --git a/openlibrary/core/waitinglist.py b/openlibrary/core/waitinglist.py index 76cce5c1442..27f4f5807e3 100644 --- a/openlibrary/core/waitinglist.py +++ b/openlibrary/core/waitinglist.py @@ -142,7 +142,6 @@ def delete(self): """ #db.delete("waitingloan", where="id=$id", vars=self) _wl_api.leave_waitinglist(self['identifier'], self['userid']) - pass def update(self, **kw): #db.update("waitingloan", where="id=$id", vars=self, **kw) diff --git a/openlibrary/coverstore/archive.py b/openlibrary/coverstore/archive.py index 3fe5f823d62..e9a65c7e7cd 100644 --- a/openlibrary/coverstore/archive.py +++ b/openlibrary/coverstore/archive.py @@ -7,7 +7,6 @@ import time from openlibrary.coverstore import config, db -from openlibrary.coverstore.coverlib import find_image_path import six diff --git a/openlibrary/coverstore/code.py b/openlibrary/coverstore/code.py index 1eff00d2139..29a1d0d0a91 100644 --- a/openlibrary/coverstore/code.py +++ b/openlibrary/coverstore/code.py @@ -6,7 +6,6 @@ import logging import os -import memcache import requests import web @@ -17,8 +16,6 @@ download, ol_get, ol_things, - random_string, - rm_f, safeint, ) from openlibrary.plugins.openlibrary.processors import CORSProcessor diff --git a/openlibrary/data/sitemap.py b/openlibrary/data/sitemap.py index 95bcc677d89..38793304197 100644 --- a/openlibrary/data/sitemap.py +++ b/openlibrary/data/sitemap.py @@ -20,7 +20,6 @@ import datetime from gzip import open as gzopen -from openlibrary.plugins.openlibrary.processors import urlsafe t = web.template.Template diff --git a/openlibrary/i18n/__init__.py b/openlibrary/i18n/__init__.py index aa2a57f3bf3..ab24abc1604 100644 --- a/openlibrary/i18n/__init__.py +++ b/openlibrary/i18n/__init__.py @@ -13,7 +13,7 @@ from babel.messages import Catalog from babel.messages.pofile import read_po, write_po from babel.messages.mofile import write_mo -from babel.messages.extract import extract_from_file, extract_from_dir, extract_python +from babel.messages.extract import extract_from_dir, extract_python root = os.path.dirname(__file__) diff --git a/openlibrary/plugins/admin/code.py b/openlibrary/plugins/admin/code.py index d51a0b0140c..0b1785681e6 100644 --- a/openlibrary/plugins/admin/code.py +++ b/openlibrary/plugins/admin/code.py @@ -9,7 +9,6 @@ import traceback import logging import json -import yaml from infogami import config from infogami.utils import delegate @@ -25,14 +24,13 @@ from openlibrary import accounts -from openlibrary.core import lending, admin as admin_stats, helpers as h, imports, cache +from openlibrary.core import admin as admin_stats, cache, helpers as h, imports from openlibrary.core.waitinglist import Stats as WLStats from openlibrary.core.sponsorships import ( summary, sync_completed_sponsored_books) from openlibrary.plugins.upstream import forms, spamcheck from openlibrary.plugins.upstream.account import send_forgot_password_email -from openlibrary.plugins.admin import services logger = logging.getLogger("openlibrary.admin") diff --git a/openlibrary/plugins/admin/mem.py b/openlibrary/plugins/admin/mem.py index 30ce5a87b22..8f0292fb0c3 100644 --- a/openlibrary/plugins/admin/mem.py +++ b/openlibrary/plugins/admin/mem.py @@ -1,4 +1,3 @@ -from infogami.utils import delegate from infogami.utils.view import render, safeint from openlibrary.plugins.admin import memory import web diff --git a/openlibrary/plugins/books/readlinks.py b/openlibrary/plugins/books/readlinks.py index c971cbc62e7..73e1714044e 100644 --- a/openlibrary/plugins/books/readlinks.py +++ b/openlibrary/plugins/books/readlinks.py @@ -10,7 +10,6 @@ import web from openlibrary.core import ia from openlibrary.core import helpers -from openlibrary.api import OpenLibrary from openlibrary.plugins.books import dynlinks from infogami.utils.delegate import register_exception from infogami.utils import stats diff --git a/openlibrary/plugins/importapi/tests/test_code_ils.py b/openlibrary/plugins/importapi/tests/test_code_ils.py index bb03c49a386..01a744e40a5 100644 --- a/openlibrary/plugins/importapi/tests/test_code_ils.py +++ b/openlibrary/plugins/importapi/tests/test_code_ils.py @@ -1,6 +1,5 @@ import datetime from openlibrary.plugins.importapi import code -from openlibrary.mocks.mock_infobase import MockSite """Tests for Koha ILS (Integrated Library System) code. """ diff --git a/openlibrary/plugins/openlibrary/api.py b/openlibrary/plugins/openlibrary/api.py index dab1033dd5a..c1efc06b3e1 100644 --- a/openlibrary/plugins/openlibrary/api.py +++ b/openlibrary/plugins/openlibrary/api.py @@ -9,17 +9,13 @@ import json from collections import defaultdict -from infogami import config from infogami.utils import delegate from infogami.utils.view import render_template # noqa: F401 used for its side effects from infogami.plugins.api.code import jsonapi -from infogami.utils.view import add_flash_message from openlibrary import accounts from openlibrary.utils.isbn import isbn_10_to_isbn_13, normalize_isbn from openlibrary.utils import extract_numeric_id_from_olid -from openlibrary.plugins.worksearch.subjects import get_subject -from openlibrary.accounts.model import OpenLibraryAccount -from openlibrary.core import ia, db, models, lending, helpers as h +from openlibrary.core import helpers as h, lending, models from openlibrary.core.observations import Observations from openlibrary.core.models import Booknotes, Work from openlibrary.core.sponsorships import qualifies_for_sponsorship diff --git a/openlibrary/plugins/openlibrary/code.py b/openlibrary/plugins/openlibrary/code.py index 95b6d9fa55f..152c6ddb2ae 100644 --- a/openlibrary/plugins/openlibrary/code.py +++ b/openlibrary/plugins/openlibrary/code.py @@ -29,7 +29,6 @@ from infogami.core.db import ValidationException from openlibrary.core import cache -from openlibrary.core.vendors import create_edition_from_amazon_metadata from openlibrary.utils.isbn import isbn_13_to_isbn_10, isbn_10_to_isbn_13 from openlibrary.core.models import Edition # noqa: E402 from openlibrary.core.lending import get_work_availability, get_edition_availability @@ -244,7 +243,6 @@ def POST(self): class clonebook(delegate.page): def GET(self): - from infogami.core.code import edit i = web.input('key') page = web.ctx.site.get(i.key) if page is None: @@ -941,7 +939,6 @@ def setup(): status.setup() authors.setup() - from openlibrary.plugins.openlibrary import api delegate.app.add_processor(web.unloadhook(stats.stats_hook)) if infogami.config.get('dev_instance') is True: diff --git a/openlibrary/plugins/openlibrary/connection.py b/openlibrary/plugins/openlibrary/connection.py index c494babc330..fee46e1556f 100644 --- a/openlibrary/plugins/openlibrary/connection.py +++ b/openlibrary/plugins/openlibrary/connection.py @@ -1,7 +1,7 @@ """Open Library extension to provide a new kind of client connection with caching support. """ from infogami import config -from infogami.infobase import client, lru +from infogami.infobase import client from infogami.utils import stats import web diff --git a/openlibrary/plugins/openlibrary/design.py b/openlibrary/plugins/openlibrary/design.py index 165fcdaa614..d283470a121 100644 --- a/openlibrary/plugins/openlibrary/design.py +++ b/openlibrary/plugins/openlibrary/design.py @@ -1,9 +1,8 @@ -import web import logging from infogami.utils import delegate -from infogami.utils.view import render_template, public +from infogami.utils.view import render_template logger = logging.getLogger("openlibrary.design") diff --git a/openlibrary/plugins/openlibrary/home.py b/openlibrary/plugins/openlibrary/home.py index 4e393ddba3b..bb101937dc3 100644 --- a/openlibrary/plugins/openlibrary/home.py +++ b/openlibrary/plugins/openlibrary/home.py @@ -8,7 +8,6 @@ from infogami.utils import delegate from infogami.utils.view import render_template, public from infogami.infobase.client import storify -from infogami import config from openlibrary.core import admin, cache, ia, lending, \ helpers as h diff --git a/openlibrary/plugins/openlibrary/lists.py b/openlibrary/plugins/openlibrary/lists.py index bd3165bc30f..a6596ee16b0 100644 --- a/openlibrary/plugins/openlibrary/lists.py +++ b/openlibrary/plugins/openlibrary/lists.py @@ -12,7 +12,6 @@ from openlibrary.core import formats, cache import openlibrary.core.helpers as h -from openlibrary.utils import dateutil from openlibrary.plugins.upstream import spamcheck from openlibrary.plugins.worksearch import subjects diff --git a/openlibrary/plugins/openlibrary/processors.py b/openlibrary/plugins/openlibrary/processors.py index 4af7bfb6e4e..a8d95829a9f 100644 --- a/openlibrary/plugins/openlibrary/processors.py +++ b/openlibrary/plugins/openlibrary/processors.py @@ -2,7 +2,6 @@ """ import web -from openlibrary.core.processors import ReadableUrlProcessor import six from openlibrary.core import helpers as h diff --git a/openlibrary/plugins/openlibrary/stats.py b/openlibrary/plugins/openlibrary/stats.py index 129838d55ed..9a010a56c2d 100644 --- a/openlibrary/plugins/openlibrary/stats.py +++ b/openlibrary/plugins/openlibrary/stats.py @@ -14,7 +14,6 @@ import web from infogami import config from infogami.utils import ( - delegate, stats, ) diff --git a/openlibrary/plugins/openlibrary/tests/test_home.py b/openlibrary/plugins/openlibrary/tests/test_home.py index f3787219920..da156e97010 100644 --- a/openlibrary/plugins/openlibrary/tests/test_home.py +++ b/openlibrary/plugins/openlibrary/tests/test_home.py @@ -1,17 +1,12 @@ import datetime -import pytest import web -from infogami.utils.view import render_template -from infogami.utils import template, context -from openlibrary.i18n import gettext from openlibrary.core.admin import Stats from openlibrary.mocks.mock_infobase import MockSite from bs4 import BeautifulSoup import six -from openlibrary import core from openlibrary.plugins.openlibrary import home class MockDoc(dict): diff --git a/openlibrary/plugins/openlibrary/tests/test_listapi.py b/openlibrary/plugins/openlibrary/tests/test_listapi.py index fadde7ac15b..77769fb385e 100644 --- a/openlibrary/plugins/openlibrary/tests/test_listapi.py +++ b/openlibrary/plugins/openlibrary/tests/test_listapi.py @@ -1,6 +1,4 @@ from __future__ import print_function -from py.test import config -import web import json import cookielib diff --git a/openlibrary/plugins/openlibrary/tests/test_ratingsapi.py b/openlibrary/plugins/openlibrary/tests/test_ratingsapi.py index b64f24501bc..393bd5fb02f 100644 --- a/openlibrary/plugins/openlibrary/tests/test_ratingsapi.py +++ b/openlibrary/plugins/openlibrary/tests/test_ratingsapi.py @@ -1,11 +1,8 @@ -from py.test import config -import web import json import cookielib from six.moves import urllib -from openlibrary.plugins.openlibrary.api import ratings from openlibrary import accounts from openlibrary.core import models diff --git a/openlibrary/plugins/openlibrary/utils.py b/openlibrary/plugins/openlibrary/utils.py index 79be1b0b2dd..e69de29bb2d 100644 --- a/openlibrary/plugins/openlibrary/utils.py +++ b/openlibrary/plugins/openlibrary/utils.py @@ -1 +0,0 @@ -from openlibrary.core.helpers import sanitize diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py index 5d1a78f504c..431ff5704b6 100644 --- a/openlibrary/plugins/upstream/account.py +++ b/openlibrary/plugins/upstream/account.py @@ -11,25 +11,22 @@ ) from infogami.infobase.client import ClientException -from infogami.utils.context import context from infogami.utils.view import safeint -import infogami.core.code as core from openlibrary import accounts from openlibrary.i18n import gettext as _ -from openlibrary.core import helpers as h, lending +from openlibrary.core import lending from openlibrary.core.booknotes import Booknotes from openlibrary.core.bookshelves import Bookshelves from openlibrary.core.observations import Observations, convert_observation_ids from openlibrary.plugins.recaptcha import recaptcha from openlibrary.plugins import openlibrary as olib from openlibrary.accounts import ( - audit_accounts, Account, OpenLibraryAccount, InternetArchiveAccount, valid_email) + audit_accounts, OpenLibraryAccount, InternetArchiveAccount, valid_email) from openlibrary.core.sponsorships import get_sponsored_editions from openlibrary.plugins.upstream import borrow, forms, utils from six.moves import range -from six.moves import urllib logger = logging.getLogger("openlibrary.account") @@ -276,7 +273,6 @@ def POST(self): payload is json. Instead, if login attempted w/ json credentials, requires Archive.org s3 keys. """ - from openlibrary.plugins.openlibrary.code import BadRequest d = json.loads(web.data()) access = d.get('access', None) secret = d.get('secret', None) diff --git a/openlibrary/plugins/upstream/addbook.py b/openlibrary/plugins/upstream/addbook.py index 349fec7d72a..7ba0bf509ce 100644 --- a/openlibrary/plugins/upstream/addbook.py +++ b/openlibrary/plugins/upstream/addbook.py @@ -6,16 +6,13 @@ import datetime from infogami import config -from infogami.core import code as core from infogami.core.db import ValidationException from infogami.utils import delegate from infogami.utils.view import safeint, add_flash_message from infogami.infobase.client import ClientException -from openlibrary.plugins.openlibrary.processors import urlsafe from openlibrary.plugins.worksearch.search import get_solr from openlibrary.utils import is_author_olid, is_work_olid -from openlibrary.i18n import gettext as _ from openlibrary import accounts import logging @@ -1049,4 +1046,3 @@ def POST(self, edition): def setup(): """Do required setup.""" - pass diff --git a/openlibrary/plugins/upstream/code.py b/openlibrary/plugins/upstream/code.py index 89acbd46a06..8aad61fa52a 100644 --- a/openlibrary/plugins/upstream/code.py +++ b/openlibrary/plugins/upstream/code.py @@ -11,12 +11,10 @@ from infogami import config from infogami.core import code as core from infogami.infobase import client -from infogami.utils import delegate, app, types +from infogami.utils import delegate from infogami.utils.view import public, safeint, render from infogami.utils.view import render_template # noqa: F401 used for its side effects -from infogami.utils.context import context -from openlibrary import accounts from openlibrary.plugins.upstream import addbook, covers, merge_authors, models, utils from openlibrary.plugins.upstream import spamcheck diff --git a/openlibrary/plugins/upstream/covers.py b/openlibrary/plugins/upstream/covers.py index f27e6609d21..2ec3734b184 100644 --- a/openlibrary/plugins/upstream/covers.py +++ b/openlibrary/plugins/upstream/covers.py @@ -3,7 +3,6 @@ from logging import getLogger import requests -import six import web from six import BytesIO diff --git a/openlibrary/plugins/upstream/data.py b/openlibrary/plugins/upstream/data.py index d79198da872..3dee3c80b1c 100644 --- a/openlibrary/plugins/upstream/data.py +++ b/openlibrary/plugins/upstream/data.py @@ -3,7 +3,6 @@ import web from infogami import config from infogami.utils import delegate -from infogami.utils.view import public import requests diff --git a/openlibrary/plugins/upstream/jsdef.py b/openlibrary/plugins/upstream/jsdef.py index f673f19a7bc..9ae68f06413 100644 --- a/openlibrary/plugins/upstream/jsdef.py +++ b/openlibrary/plugins/upstream/jsdef.py @@ -56,7 +56,7 @@ import json import web -from web.template import Template, Parser, LineNode, SuiteNode, DefNode, PythonTokenizer, INDENT +from web.template import DefNode, INDENT, PythonTokenizer def extension(parser): r"""jsdef extension. Adds support for `jsdef` block to template parser.:: diff --git a/openlibrary/plugins/upstream/models.py b/openlibrary/plugins/upstream/models.py index 6020e54bd96..b812f02d48f 100644 --- a/openlibrary/plugins/upstream/models.py +++ b/openlibrary/plugins/upstream/models.py @@ -4,14 +4,12 @@ import re from functools import cached_property -import requests import sys import web from collections import defaultdict from isbnlib import canonical -from infogami import config from infogami.infobase import client from infogami.utils.view import safeint from infogami.utils import stats @@ -20,8 +18,7 @@ from openlibrary.core.models import Image from openlibrary.core import lending -from openlibrary.plugins.upstream.utils import get_coverstore_url, MultiDict, parse_toc, get_edition_config -from openlibrary.plugins.upstream import account +from openlibrary.plugins.upstream.utils import MultiDict, get_edition_config, parse_toc from openlibrary.plugins.upstream import borrow from openlibrary.plugins.worksearch.code import works_by_author, sorted_work_editions from openlibrary.plugins.worksearch.search import get_solr diff --git a/openlibrary/plugins/upstream/tests/test_borrow.py b/openlibrary/plugins/upstream/tests/test_borrow.py index 21cbc73bb5b..4efc1c0e40a 100644 --- a/openlibrary/plugins/upstream/tests/test_borrow.py +++ b/openlibrary/plugins/upstream/tests/test_borrow.py @@ -1,4 +1,2 @@ """py.test tests for borrow.py""" -import web -from .. import borrow diff --git a/openlibrary/plugins/upstream/utils.py b/openlibrary/plugins/upstream/utils.py index bd82fa01325..2ba1282870b 100644 --- a/openlibrary/plugins/upstream/utils.py +++ b/openlibrary/plugins/upstream/utils.py @@ -19,14 +19,14 @@ from infogami import config from infogami.utils import view, delegate, stats -from infogami.utils.view import render, get_template, public, query_param +from infogami.utils.view import get_template, public, render from infogami.utils.macro import macro from infogami.utils.context import context from infogami.infobase.client import Thing, Changeset, storify from openlibrary.core.helpers import commify, parse_datetime from openlibrary.core.middleware import GZipMiddleware -from openlibrary.core import cache, ab +from openlibrary.core import cache class MultiDict(MutableMapping): """Ordered Dictionary that can store multiple values. diff --git a/openlibrary/plugins/worksearch/languages.py b/openlibrary/plugins/worksearch/languages.py index a74a9085983..34a2f2a7319 100644 --- a/openlibrary/plugins/worksearch/languages.py +++ b/openlibrary/plugins/worksearch/languages.py @@ -2,8 +2,8 @@ """ from infogami.plugins.api.code import jsonapi -from infogami.utils import delegate, stats -from infogami.utils.view import render_template, safeint +from infogami.utils import delegate +from infogami.utils.view import render_template import web import json import logging @@ -11,7 +11,6 @@ from . import subjects from . import search -from six.moves import urllib logger = logging.getLogger("openlibrary.worksearch") diff --git a/openlibrary/plugins/worksearch/publishers.py b/openlibrary/plugins/worksearch/publishers.py index d99d9bd4730..972b93a3d59 100644 --- a/openlibrary/plugins/worksearch/publishers.py +++ b/openlibrary/plugins/worksearch/publishers.py @@ -1,14 +1,13 @@ """Publisher pages """ -from infogami.utils import delegate, stats -from infogami.utils.view import render_template, safeint +from infogami.utils import delegate +from infogami.utils.view import render_template import web import logging from . import subjects from . import search -from six.moves import urllib logger = logging.getLogger("openlibrary.worksearch") diff --git a/openlibrary/plugins/worksearch/subjects.py b/openlibrary/plugins/worksearch/subjects.py index 7f2be61e48e..f954cb29487 100644 --- a/openlibrary/plugins/worksearch/subjects.py +++ b/openlibrary/plugins/worksearch/subjects.py @@ -12,7 +12,7 @@ from infogami import config from infogami.plugins.api.code import jsonapi from infogami.utils import delegate, stats -from infogami.utils.view import render, render_template, safeint +from infogami.utils.view import render_template, safeint from openlibrary.core.models import Subject from openlibrary.core.lending import add_availability @@ -429,4 +429,3 @@ def setup(): This function is called from code.py. """ - pass diff --git a/openlibrary/plugins/worksearch/tests/test_worksearch.py b/openlibrary/plugins/worksearch/tests/test_worksearch.py index aa130d3e6d3..a49535c281c 100644 --- a/openlibrary/plugins/worksearch/tests/test_worksearch.py +++ b/openlibrary/plugins/worksearch/tests/test_worksearch.py @@ -1,8 +1,7 @@ from __future__ import print_function import pytest -from openlibrary.plugins.worksearch.code import read_facets, sorted_work_editions, parse_query_fields, escape_bracket, run_solr_query, get_doc, build_q_list, escape_colon, parse_search_response +from openlibrary.plugins.worksearch.code import build_q_list, escape_bracket, escape_colon, get_doc, parse_query_fields, parse_search_response, read_facets, sorted_work_editions from lxml import etree -from infogami import config def test_escape_bracket(): assert escape_bracket('foo') == 'foo' diff --git a/openlibrary/records/__init__.py b/openlibrary/records/__init__.py index 80b669d7c86..139597f9cb0 100644 --- a/openlibrary/records/__init__.py +++ b/openlibrary/records/__init__.py @@ -1,4 +1,2 @@ -from .driver import search -from .functions import create diff --git a/openlibrary/records/functions.py b/openlibrary/records/functions.py index e0785e13b5c..0ea8cb18a1e 100644 --- a/openlibrary/records/functions.py +++ b/openlibrary/records/functions.py @@ -8,16 +8,13 @@ import web -from openlibrary.catalog.add_book import normalize from openlibrary.core.models import Thing -import openlibrary.core.helpers as h class NoQueryParam(KeyError): """ Exception that is used internally when a find_by_X function is called but no X parameters were provided. """ - pass def search(params): diff --git a/openlibrary/records/matchers.py b/openlibrary/records/matchers.py index 8c0115c5ee2..44326df9af4 100644 --- a/openlibrary/records/matchers.py +++ b/openlibrary/records/matchers.py @@ -24,8 +24,6 @@ from collections import defaultdict import logging as Logging -from infogami import config -from openlibrary.utils.solr import Solr import web diff --git a/openlibrary/solr/data_provider.py b/openlibrary/solr/data_provider.py index 15d6f1a4503..f9b52741822 100644 --- a/openlibrary/solr/data_provider.py +++ b/openlibrary/solr/data_provider.py @@ -64,14 +64,12 @@ def preload_documents(self, keys): :param list of str keys: type-prefixed keys to load (ex: /books/OL1M) :return: None """ - pass def preload_metadata(self, identifiers): """ :param list of str identifiers: list of Internet Archive ids (aka ocaids) :return: """ - pass def preload_editions_of_works(self, work_keys): """ @@ -81,7 +79,6 @@ def preload_editions_of_works(self, work_keys): :param list of str work_keys: type-prefixed keys to work keys (ex: /works/OL1W) :return: None """ - pass def find_redirects(self, key): """ diff --git a/openlibrary/solr/db_load_works.py b/openlibrary/solr/db_load_works.py index e2afec2f077..5627a475796 100644 --- a/openlibrary/solr/db_load_works.py +++ b/openlibrary/solr/db_load_works.py @@ -1,7 +1,6 @@ from __future__ import print_function import web import re -import json db = web.database(dbn='mysql', user='root', passwd='', db='openlibrary') db.printing = False diff --git a/openlibrary/solr/update_work.py b/openlibrary/solr/update_work.py index b25309d4eec..c02d80c7ead 100644 --- a/openlibrary/solr/update_work.py +++ b/openlibrary/solr/update_work.py @@ -24,12 +24,9 @@ import web from lxml.etree import tostring, Element, SubElement -from infogami.infobase.client import ClientException from openlibrary import config -from openlibrary.catalog.utils.query import set_query_host, base_url as get_ol_base_url +from openlibrary.catalog.utils.query import set_query_host from openlibrary.core import helpers as h -from openlibrary.core import ia -from openlibrary.plugins.upstream.utils import url_quote from openlibrary.solr.data_provider import get_data_provider, DataProvider from openlibrary.utils.ddc import normalize_ddc, choose_sorting_ddc from openlibrary.utils.isbn import opposite_isbn @@ -1132,7 +1129,6 @@ def _get_requests(self): def _add_request(self, doc): """Constructs add request using doc dict. """ - pass class UpdateRequest: """A Solr request.""" diff --git a/scripts/2009/01/dumps/jsondump.py b/scripts/2009/01/dumps/jsondump.py index 0f471754c1f..74b617244ea 100644 --- a/scripts/2009/01/dumps/jsondump.py +++ b/scripts/2009/01/dumps/jsondump.py @@ -54,7 +54,6 @@ def json2rawdump(jsonfile): def bookdump(rawdump): """Generates bookdump from rawdump. """ - pass @command def modified(db, date): diff --git a/scripts/2009/10/loadmemcache.py b/scripts/2009/10/loadmemcache.py index d01e0d8dcb1..c601e75f518 100644 --- a/scripts/2009/10/loadmemcache.py +++ b/scripts/2009/10/loadmemcache.py @@ -1,4 +1,3 @@ -import _init_path from openlibrary.utils import olmemcache import web import time diff --git a/scripts/2009/10/loadworks.py b/scripts/2009/10/loadworks.py index 84ac1dc19e4..a48d60c61ae 100644 --- a/scripts/2009/10/loadworks.py +++ b/scripts/2009/10/loadworks.py @@ -1,10 +1,8 @@ """Script to load works fast.""" import sys, os import time -import simplejson import web -import _init_path from openlibrary.utils.bulkimport import DocumentLoader, Reindexer class WorkLoader: diff --git a/scripts/2009/12/fix_no_index.py b/scripts/2009/12/fix_no_index.py index 82e482b6663..2e7a3880872 100644 --- a/scripts/2009/12/fix_no_index.py +++ b/scripts/2009/12/fix_no_index.py @@ -1,5 +1,5 @@ -from openlibrary.catalog.utils.query import query, withKey -from openlibrary.api import OpenLibrary, unmarshal +from openlibrary.catalog.utils.query import query +from openlibrary.api import OpenLibrary from openlibrary.catalog.read_rc import read_rc rc = read_rc() diff --git a/scripts/2011/02/fix_redirects.py b/scripts/2011/02/fix_redirects.py index f02a6d4e6d5..ae2b192a47e 100644 --- a/scripts/2011/02/fix_redirects.py +++ b/scripts/2011/02/fix_redirects.py @@ -14,7 +14,6 @@ import yaml import memcache -import _init_path from infogami.infobase.server import parse_db_parameters from openlibrary.data import db diff --git a/scripts/2011/05/account_v2_migration.py b/scripts/2011/05/account_v2_migration.py index e5d28e24a64..c1059ce580f 100644 --- a/scripts/2011/05/account_v2_migration.py +++ b/scripts/2011/05/account_v2_migration.py @@ -5,13 +5,11 @@ $ python account_v2_migration.py infobase.yml """ from __future__ import with_statement -import _init_path from infogami.infobase import server from infogami.infobase._dbstore.store import Store import sys -import yaml import web def migrate_account_table(db): diff --git a/scripts/ipstats.py b/scripts/ipstats.py index 87454faaa5d..2602c2e1b73 100755 --- a/scripts/ipstats.py +++ b/scripts/ipstats.py @@ -13,7 +13,6 @@ import os import subprocess import web -import _init_path import infogami # must be after _init_path from openlibrary.config import load_config diff --git a/scripts/lc_marc_update.py b/scripts/lc_marc_update.py index b64c9551828..005fb157247 100755 --- a/scripts/lc_marc_update.py +++ b/scripts/lc_marc_update.py @@ -2,7 +2,6 @@ from __future__ import print_function from openlibrary.catalog.importer.scribe import BadImport -from openlibrary.catalog.read_rc import read_rc from openlibrary import config from ftplib import FTP from time import sleep diff --git a/scripts/legacy/solr_author_merge_work_finder.py b/scripts/legacy/solr_author_merge_work_finder.py index e8fb40f9099..6df3ddc037c 100755 --- a/scripts/legacy/solr_author_merge_work_finder.py +++ b/scripts/legacy/solr_author_merge_work_finder.py @@ -1,7 +1,6 @@ #!/usr/bin/python from __future__ import print_function -import _init_path from openlibrary import config import argparse diff --git a/scripts/manage-imports.py b/scripts/manage-imports.py index 78911647f4e..2bcda4c7bad 100755 --- a/scripts/manage-imports.py +++ b/scripts/manage-imports.py @@ -6,7 +6,6 @@ import logging import datetime import time -import _init_path from openlibrary.config import load_config from openlibrary.api import OpenLibrary, OLError from openlibrary.core.ia import get_candidate_ocaids diff --git a/scripts/minicron.py b/scripts/minicron.py index 22e309c05cd..6f993509677 100755 --- a/scripts/minicron.py +++ b/scripts/minicron.py @@ -4,7 +4,6 @@ import datetime import logging import optparse -import _init_path from openlibrary.core import minicron diff --git a/scripts/new-solr-updater.py b/scripts/new-solr-updater.py index e878e49022f..fcc7ddcdf13 100755 --- a/scripts/new-solr-updater.py +++ b/scripts/new-solr-updater.py @@ -6,7 +6,6 @@ 2013-02-25: First version 2018-02-11: Use newer config method """ -import _init_path from six.moves import urllib import logging diff --git a/scripts/oldump.py b/scripts/oldump.py index fe94c6fb960..51597ef0002 100755 --- a/scripts/oldump.py +++ b/scripts/oldump.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -import _init_path from openlibrary.data import dump if __name__ == "__main__": diff --git a/scripts/pull-templates.py b/scripts/pull-templates.py index f9570a88544..7209cb63c66 100755 --- a/scripts/pull-templates.py +++ b/scripts/pull-templates.py @@ -2,7 +2,6 @@ """Script to pull templates and macros from an openlibrary instance to repository. """ from __future__ import print_function -import _init_path import os import web diff --git a/scripts/store_counts.py b/scripts/store_counts.py index 505ec815339..78b632cb9eb 100755 --- a/scripts/store_counts.py +++ b/scripts/store_counts.py @@ -3,7 +3,6 @@ from __future__ import print_function import sys -import _init_path from openlibrary.admin import stats