Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all the unused imports are removed #5555

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion openlibrary/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion openlibrary/catalog/add_book/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
response = load(record)

"""
import json
import re

import unicodedata as ucd
Expand Down
3 changes: 1 addition & 2 deletions openlibrary/catalog/marc/marc_subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
3 changes: 0 additions & 3 deletions openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def setup():
load_views()

# load actions
from . import actions

logger.info("loading complete.")

Expand All @@ -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()
4 changes: 0 additions & 4 deletions openlibrary/core/lists/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
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

from openlibrary.plugins.worksearch.search import get_solr

import six
from six.moves import urllib


logger = logging.getLogger("openlibrary.lists.model")
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from openlibrary.core.vendors import create_edition_from_amazon_metadata

# Seed might look unused, but removing it causes an error :/
Copy link
Collaborator

@hornc hornc Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment looks relevant:
# Seed might look unused, but removing it causes an error :/

I believe there are unfortunately a number of cases in older OL code where things are imported in a file to be used elsewhere and it's not indicated clearly that the module is supposed to provide that interface.

from openlibrary.core.lists.model import ListMixin, Seed
from openlibrary.core.lists.model import ListMixin
from . import cache, waitinglist

from six.moves import urllib
Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/processors/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from openlibrary.core.processors.readableurls import ReadableUrlProcessor
3 changes: 1 addition & 2 deletions openlibrary/core/sponsorships.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion openlibrary/core/waitinglist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion openlibrary/coverstore/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import time

from openlibrary.coverstore import config, db
from openlibrary.coverstore.coverlib import find_image_path

import six

Expand Down
3 changes: 0 additions & 3 deletions openlibrary/coverstore/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import logging
import os

import memcache
import requests
import web

Expand All @@ -17,8 +16,6 @@
download,
ol_get,
ol_things,
random_string,
rm_f,
safeint,
)
from openlibrary.plugins.openlibrary.processors import CORSProcessor
Expand Down
1 change: 0 additions & 1 deletion openlibrary/data/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import datetime
from gzip import open as gzopen

from openlibrary.plugins.openlibrary.processors import urlsafe

t = web.template.Template

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/i18n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
4 changes: 1 addition & 3 deletions openlibrary/plugins/admin/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import traceback
import logging
import json
import yaml

from infogami import config
from infogami.utils import delegate
Expand All @@ -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")
Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/admin/mem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from infogami.utils import delegate
from infogami.utils.view import render, safeint
from openlibrary.plugins.admin import memory
import web
Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/books/readlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/importapi/tests/test_code_ils.py
Original file line number Diff line number Diff line change
@@ -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.
"""

Expand Down
6 changes: 1 addition & 5 deletions openlibrary/plugins/openlibrary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions openlibrary/plugins/openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/openlibrary/connection.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions openlibrary/plugins/openlibrary/design.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/openlibrary/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/openlibrary/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/openlibrary/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
import web

from openlibrary.core.processors import ReadableUrlProcessor
import six

from openlibrary.core import helpers as h
Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/openlibrary/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import web
from infogami import config
from infogami.utils import (
delegate,
stats,
)

Expand Down
5 changes: 0 additions & 5 deletions openlibrary/plugins/openlibrary/tests/test_home.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 0 additions & 2 deletions openlibrary/plugins/openlibrary/tests/test_listapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from __future__ import print_function
from py.test import config
import web
import json

import cookielib
Expand Down
3 changes: 0 additions & 3 deletions openlibrary/plugins/openlibrary/tests/test_ratingsapi.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion openlibrary/plugins/openlibrary/utils.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from openlibrary.core.helpers import sanitize
8 changes: 2 additions & 6 deletions openlibrary/plugins/upstream/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions openlibrary/plugins/upstream/addbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1049,4 +1046,3 @@ def POST(self, edition):

def setup():
"""Do required setup."""
pass
Loading