id
int64
0
458k
file_name
stringlengths
4
119
file_path
stringlengths
14
227
content
stringlengths
24
9.96M
size
int64
24
9.96M
language
stringclasses
1 value
extension
stringclasses
14 values
total_lines
int64
1
219k
avg_line_length
float64
2.52
4.63M
max_line_length
int64
5
9.91M
alphanum_fraction
float64
0
1
repo_name
stringlengths
7
101
repo_stars
int64
100
139k
repo_forks
int64
0
26.4k
repo_open_issues
int64
0
2.27k
repo_license
stringclasses
12 values
repo_extraction_date
stringclasses
433 values
300
test_processors.py
internetarchive_openlibrary/openlibrary/tests/core/test_processors.py
from openlibrary.core.processors import readableurls as processors from infogami.infobase import client, common import web class MockSite: def __init__(self): self.docs = {} self.olids = {} def get(self, key): return self.docs.get(key) def add(self, doc): # @@ UGLY! ...
3,490
Python
.py
90
32.511111
86
0.593694
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
301
test_wikidata.py
internetarchive_openlibrary/openlibrary/tests/core/test_wikidata.py
import pytest from unittest.mock import patch from openlibrary.core import wikidata from datetime import datetime, timedelta EXAMPLE_WIKIDATA_DICT = { 'id': "Q42", 'type': 'str', 'labels': {'en': ''}, 'descriptions': {'en': ''}, 'aliases': {'en': ['']}, 'statements': {'': {}}, 'sitelinks': ...
2,429
Python
.py
68
29.235294
81
0.630952
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
302
test_models.py
internetarchive_openlibrary/openlibrary/tests/core/test_models.py
from openlibrary.core import models import pytest class MockSite: def get(self, key): return models.Thing(self, key, data={}) def _get_backreferences(self, thing): return {} class MockLendableEdition(models.Edition): def get_ia_collections(self): return ['lendinglibrary'] cla...
6,092
Python
.py
140
34.678571
87
0.5827
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
303
test_i18n.py
internetarchive_openlibrary/openlibrary/tests/core/test_i18n.py
import web from openlibrary.mocks.mock_infobase import MockSite # The i18n module should be moved to core. from openlibrary import i18n class MockTranslations(dict): def gettext(self, message): return self.get(message, message) def ungettext(self, message1, message2, n): if n == 1: ...
2,465
Python
.py
65
28.846154
78
0.566204
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
304
test_model.py
internetarchive_openlibrary/openlibrary/tests/core/lists/test_model.py
from openlibrary.mocks.mock_infobase import MockSite import openlibrary.core.lists.model as list_model class TestList: def test_owner(self): list_model.register_models() self._test_list_owner("/people/anand") self._test_list_owner("/people/anand-test") self._test_list_owner("/peopl...
908
Python
.py
22
33.590909
52
0.625711
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
305
mock_infobase.py
internetarchive_openlibrary/openlibrary/mocks/mock_infobase.py
"""Simple implementation of mock infogami site to use in testing. """ import glob import itertools import json import re import pytest import web from datetime import datetime from infogami.infobase import client, common, account, config as infobase_config from infogami import config from openlibrary.plugins.upstrea...
13,718
Python
.py
363
27.633609
99
0.554173
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
306
mock_ol.py
internetarchive_openlibrary/openlibrary/mocks/mock_ol.py
import pytest import re import web from infogami import config from infogami.utils import delegate try: # newer versions of web.py from web.browser import AppBrowser except ImportError: # older versions of web.py from web import AppBrowser from openlibrary.mocks.mock_infobase import mock_site, MockConnectio...
2,716
Python
.py
71
30.366197
85
0.642584
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
307
mock_memcache.py
internetarchive_openlibrary/openlibrary/mocks/mock_memcache.py
"""Library to mock memcache functionality. """ import memcache import pytest class Client: """Mock memcache client.""" def __init__(self, servers=None): servers = servers or [] self.servers = servers self.cache = {} def set(self, key, value): self.cache[key] = value ...
1,174
Python
.py
37
25
91
0.621766
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
308
mock_ia.py
internetarchive_openlibrary/openlibrary/mocks/mock_ia.py
"""Mock of openlibrary.core.ia module. """ import pytest from openlibrary.core import ia @pytest.fixture def mock_ia(request, monkeypatch): """pytest funcarg to mock openlibrary.core.ia module. from openlibrary.core import ia def test_ia(mock_ia): assert ia.get_metadata("foo") == {} mo...
751
Python
.py
22
28.136364
67
0.628651
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
309
test_mock_memcache.py
internetarchive_openlibrary/openlibrary/mocks/tests/test_mock_memcache.py
from .. import mock_memcache import memcache class Test_mock_memcache: def test_set(self): m = mock_memcache.Client([]) m.set("a", 1) assert m.get("a") == 1 m.set("a", "foo") assert m.get("a") == "foo" m.set("a", ["foo", "bar"]) assert m.get("a") == ["foo...
632
Python
.py
20
24.8
47
0.535
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
310
test_mock_infobase.py
internetarchive_openlibrary/openlibrary/mocks/tests/test_mock_infobase.py
import datetime import web class TestMockSite: def test_new_key(self, mock_site): ekey = mock_site.new_key('/type/edition') assert ekey == '/books/OL1M' ekey = mock_site.new_key('/type/edition') assert ekey == '/books/OL2M' wkey = mock_site.new_key('/type/work') as...
4,736
Python
.py
96
39.59375
150
0.553823
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
311
formats.py
internetarchive_openlibrary/openlibrary/core/formats.py
"""Library for loading and dumping data to json and yaml. """ import json import yaml from openlibrary.core.helpers import NothingEncoder __all__ = ["load_yaml", "dump_yaml"] def load_yaml(text): return yaml.safe_load(text) def dump_yaml(data): return yaml.safe_dump(data, indent=4, allow_unicode=True, de...
781
Python
.py
24
27.75
87
0.679625
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
312
db.py
internetarchive_openlibrary/openlibrary/core/db.py
"""Interface to access the database of openlibrary. """ import web import sqlite3 from datetime import datetime from sqlite3 import IntegrityError from psycopg2.errors import UniqueViolation from infogami.utils import stats @web.memoize def _get_db(): return web.database(**web.config.db_parameters) def get_db(...
5,780
Python
.py
158
26.78481
86
0.572961
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
313
models.py
internetarchive_openlibrary/openlibrary/core/models.py
"""Models of various OL objects. """ from datetime import datetime, timedelta import logging from openlibrary.core.vendors import get_amazon_metadata import web import json import requests from typing import Any, TypedDict from collections import defaultdict from dataclasses import dataclass, field from infogami.inf...
44,419
Python
.py
1,032
33.119186
139
0.587445
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
314
bookshelves_events.py
internetarchive_openlibrary/openlibrary/core/bookshelves_events.py
from datetime import datetime from enum import IntEnum from . import db class BookshelfEvent(IntEnum): START = 1 UPDATE = 2 FINISH = 3 @classmethod def has_value(cls, value: int) -> bool: return value in (item.value for item in BookshelfEvent.__members__.values()) class BookshelvesEven...
5,616
Python
.py
168
23.803571
85
0.554836
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
315
sendmail.py
internetarchive_openlibrary/openlibrary/core/sendmail.py
from infogami import config from infogami.utils.view import render_template import web def sendmail_with_template(template, to, cc=None, frm=None, **kwargs): msg = render_template(template, **kwargs) _sendmail(to, msg, cc=cc, frm=frm) def _sendmail(to, msg, cc=None, frm=None): cc = cc or [] frm = fr...
738
Python
.py
21
28
81
0.61236
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
316
yearly_reading_goals.py
internetarchive_openlibrary/openlibrary/core/yearly_reading_goals.py
from datetime import date, datetime from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO from . import db class YearlyReadingGoals: TABLENAME = 'yearly_reading_goals' @classmethod def summary(cls): return { 'total_yearly_reading_goals': { 'tota...
4,148
Python
.py
115
26.504348
86
0.577173
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
317
batch_imports.py
internetarchive_openlibrary/openlibrary/core/batch_imports.py
from dataclasses import dataclass import json import hashlib from json.decoder import JSONDecodeError from pydantic import ValidationError from pydantic_core import ErrorDetails from openlibrary import accounts from openlibrary.core.imports import Batch from openlibrary.plugins.importapi.import_edition_builder import...
4,647
Python
.py
115
32.869565
101
0.664964
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
318
observations.py
internetarchive_openlibrary/openlibrary/core/observations.py
"""Module for handling patron observation functionality""" from collections import defaultdict, namedtuple from infogami import config from infogami.utils.view import public from openlibrary.utils import extract_numeric_id_from_olid from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO from . ...
40,055
Python
.py
1,006
26.978131
110
0.470984
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
319
vendors.py
internetarchive_openlibrary/openlibrary/core/vendors.py
from __future__ import annotations import logging import re import time from datetime import date from typing import Any, Literal import requests from dateutil import parser as isoparser from infogami.utils.view import public from paapi5_python_sdk.api.default_api import DefaultApi from paapi5_python_sdk.get_items_re...
22,018
Python
.py
543
32.186004
112
0.620741
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
320
fulltext.py
internetarchive_openlibrary/openlibrary/core/fulltext.py
import json import logging import requests import web from infogami import config from openlibrary.core.lending import get_availability_of_ocaids from openlibrary.plugins.openlibrary.home import format_book_data from urllib.parse import urlencode logger = logging.getLogger("openlibrary.inside") def fulltext_search_...
2,209
Python
.py
54
32.796296
88
0.624127
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
321
booknotes.py
internetarchive_openlibrary/openlibrary/core/booknotes.py
from . import db from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO class Booknotes(db.CommonExtras): TABLENAME = "booknotes" PRIMARY_KEY = ["username", "work_id", "edition_id"] NULL_EDITION_VALUE = -1 ALLOW_DELETE_ON_CONFLICT = False @classmethod def summary(cls) -...
7,617
Python
.py
197
28.456853
88
0.568262
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
322
cache.py
internetarchive_openlibrary/openlibrary/core/cache.py
"""Caching utilities. """ import hashlib import random import string import time import threading import functools from typing import Any, Literal, cast from collections.abc import Callable import memcache import json import web from infogami import config from infogami.utils import stats from infogami.infobase.clie...
17,630
Python
.py
453
30.154525
123
0.60674
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
323
olmarkdown.py
internetarchive_openlibrary/openlibrary/core/olmarkdown.py
"""Open Library Flavored Markdown, inspired by [Github Flavored Markdown][GFM]. GFM: http://github.github.com/github-flavored-markdown/ Differences from traditional Markdown: * new lines in paragraph are treated as line breaks * URLs are autolinked * generated HTML is sanitized The custom changes done here to markdo...
2,735
Python
.py
61
38.098361
118
0.661011
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
324
__init__.py
internetarchive_openlibrary/openlibrary/core/__init__.py
"""Core functionality of Open Library. This is a set of reusable, easily testable modules. """
96
Python
.py
3
30.666667
51
0.771739
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
325
waitinglist.py
internetarchive_openlibrary/openlibrary/core/waitinglist.py
"""Implementation of waiting-list feature for OL loans. Each waiting instance is represented as a document in the store as follows: { "_key": "waiting-loan-OL123M-anand", "type": "waiting-loan", "user": "/people/anand", "book": "/books/OL123M", "status": "waiting", ...
9,833
Python
.py
244
32.643443
89
0.634646
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
326
follows.py
internetarchive_openlibrary/openlibrary/core/follows.py
import logging from typing import cast from openlibrary.core.bookshelves import Bookshelves from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO from . import db logger = logging.getLogger(__name__) class PubSub: TABLENAME = "follows" PRIMARY_KEY = ["subscriber", "publisher"] @c...
5,576
Python
.py
148
28.324324
136
0.599556
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
327
admin.py
internetarchive_openlibrary/openlibrary/core/admin.py
"""Admin functionality.""" import calendar import datetime import requests import web from infogami import config from openlibrary.core import cache class Stats: def __init__(self, docs, key, total_key): self.key = key self.docs = docs try: self.latest = docs[-1].get(key, 0)...
6,042
Python
.py
143
33.769231
88
0.603851
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
328
middleware.py
internetarchive_openlibrary/openlibrary/core/middleware.py
"""WSGI middleware used in Open Library. """ import web from io import BytesIO import gzip class GZipMiddleware: """WSGI middleware to gzip the response.""" def __init__(self, app): self.app = app def __call__(self, environ, start_response): accept_encoding = environ.get("HTTP_ACCEPT_EN...
1,539
Python
.py
40
27.9
65
0.571909
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
329
ia.py
internetarchive_openlibrary/openlibrary/core/ia.py
"""Library for interacting with archive.org. """ import datetime import logging from urllib.parse import urlencode import requests import web from infogami import config from infogami.utils import stats from openlibrary.core import cache logger = logging.getLogger('openlibrary.ia') # FIXME: We can't reference `con...
11,615
Python
.py
289
31.598616
92
0.6041
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
330
statsdb.py
internetarchive_openlibrary/openlibrary/core/statsdb.py
"""Interface to Open Library stats database. The stats table in the openlibrary database is of the following schema: CREATE TABLE stats ( id serial primary key, key text unique, type text, timestamp timestamp without time zone, json text ); see schema.py for more detai...
1,999
Python
.py
53
32.056604
87
0.669083
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
331
wikidata.py
internetarchive_openlibrary/openlibrary/core/wikidata.py
""" The purpose of this file is to: 1. Interact with the Wikidata API 2. Store the results 3. Make the results easy to access from other files """ import requests import logging from dataclasses import dataclass from openlibrary.core.helpers import days_since from datetime import datetime import json from openlibrary...
4,545
Python
.py
119
31.638655
103
0.658714
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
332
seq.py
internetarchive_openlibrary/openlibrary/core/seq.py
"""Library to generate keys for new documents using database sequences. Currently new keys are generated for author, edition and work types. """ __all__ = ["get_new_key", "get_new_keys"] def get_new_key(site, type): """Returns a new key for the given type of document.""" return site.new_key(type) def get_...
602
Python
.py
14
38.642857
71
0.659208
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
333
stats.py
internetarchive_openlibrary/openlibrary/core/stats.py
""" StatsD client to be used in the application to log various metrics Based on the code in http://www.monkinetic.com/2011/02/statsd.html (pystatsd client) """ # statsd.py # Steve Ivy <steveivy@gmail.com> # http://monkinetic.com import logging from statsd import StatsClient from infogami import config pystats_l...
2,007
Python
.py
52
32.230769
88
0.664256
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
334
imports.py
internetarchive_openlibrary/openlibrary/core/imports.py
"""Interface to import queue. """ from collections import defaultdict from collections.abc import Iterable from typing import TYPE_CHECKING, Any, Final import logging import datetime import time import web import json from psycopg2.errors import UndefinedTable, UniqueViolation from pydantic import ValidationError fr...
15,668
Python
.py
388
29.703608
105
0.565898
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
335
schema.py
internetarchive_openlibrary/openlibrary/core/schema.py
"""Infobase schema for Open Library """ from infogami.infobase import dbstore import web def get_schema(): schema = dbstore.Schema() schema.add_table_group('type', '/type/type') schema.add_table_group('type', '/type/property') schema.add_table_group('type', '/type/backreference') schema.add_table...
4,142
Python
.py
95
37.221053
96
0.670974
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
336
edits.py
internetarchive_openlibrary/openlibrary/core/edits.py
import datetime import json import web from sqlite3 import IntegrityError from psycopg2.errors import UniqueViolation from infogami.utils.view import public from openlibrary.i18n import gettext as _ from openlibrary.core import cache from openlibrary.utils import dateutil from . import db @public def get_status_fo...
10,286
Python
.py
281
27.014235
91
0.574415
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
337
bookshelves.py
internetarchive_openlibrary/openlibrary/core/bookshelves.py
import logging import web from dataclasses import dataclass from datetime import date, datetime from typing import Literal, cast, Any, Final, TypedDict from collections.abc import Iterable from openlibrary.plugins.worksearch.search import get_solr from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WE...
30,768
Python
.py
683
33.68082
145
0.577828
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
338
lending.py
internetarchive_openlibrary/openlibrary/core/lending.py
"""Module for providing core functionality of lending on Open Library. """ from typing import TYPE_CHECKING, Literal, TypedDict, cast import web import datetime import logging import time import uuid import eventer import requests from simplejson.errors import JSONDecodeError from infogami.utils.view import public...
37,165
Python
.py
915
32.893989
103
0.628724
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
339
ratings.py
internetarchive_openlibrary/openlibrary/core/ratings.py
from math import sqrt from typing import TypedDict from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO from . import db class WorkRatingsSummary(TypedDict): ratings_average: float ratings_sortable: float ratings_count: int ratings_count_1: int ratings_count_2: int ra...
8,310
Python
.py
198
31.934343
88
0.571658
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
340
readableurls.py
internetarchive_openlibrary/openlibrary/core/processors/readableurls.py
"""Various web.py application processors used in OL. """ import logging import os import web from infogami.utils.view import render from openlibrary.core import helpers as h import urllib logger = logging.getLogger("openlibrary.readableurls") try: from booklending_utils.openlibrary import is_exclusion except I...
6,631
Python
.py
157
33.828025
100
0.5925
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
341
invalidation.py
internetarchive_openlibrary/openlibrary/core/processors/invalidation.py
import web import datetime from infogami.infobase import client from openlibrary.core import helpers as h import contextlib __all__ = ["InvalidationProcessor"] class InvalidationProcessor: """Application processor to invalidate/update locally cached documents. The openlibrary application caches some docume...
6,179
Python
.py
134
37.298507
100
0.659
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
342
engine.py
internetarchive_openlibrary/openlibrary/core/lists/engine.py
"""Utility functions for processing lists. """ import collections import re def reduce_seeds(values): """Function to reduce the seed values got from works db.""" d = { "works": 0, "editions": 0, "ebooks": 0, "last_update": "", } subject_processor = SubjectProcessor() ...
3,220
Python
.py
78
33
109
0.568722
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
343
model.py
internetarchive_openlibrary/openlibrary/core/lists/model.py
"""Helper functions used by the List model. """ from collections.abc import Iterable from functools import cached_property from typing import TypedDict, cast import web import logging from infogami import config from infogami.infobase import client, common from infogami.utils import stats from openlibrary.core impo...
19,851
Python
.py
521
27.71977
96
0.557006
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
344
matchers.py
internetarchive_openlibrary/openlibrary/records/matchers.py
""" Matchers ======== This module contains a list of functions that are used to search for records in the database. Each function will receive a dictionary that contains the search parameters. This shouldn't be modified (make a copy if you have to modify it). It can do whatever kinds of searches it wants to and then ...
2,688
Python
.py
66
35.484848
85
0.679754
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
345
functions.py
internetarchive_openlibrary/openlibrary/records/functions.py
""" Functions which are used by the records package. The two public ones are `search` and `create` which are callable from the outside world. """ import copy import web from openlibrary.catalog.add_book import normalize from openlibrary.core.models import Thing import openlibrary.core.helpers as h class NoQueryPar...
12,612
Python
.py
337
29.967359
91
0.606038
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
346
driver.py
internetarchive_openlibrary/openlibrary/records/driver.py
""" Low level import API ==================== The Low level import API functions has 2 stages. 1. Matchers ----------- The matchers are functions present in the ``matchers`` module and exposed via the ``match_functions`` list. These are functions that try to search for entries in the database that match the input cr...
4,481
Python
.py
106
33.59434
95
0.631361
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
347
test_functions.py
internetarchive_openlibrary/openlibrary/records/tests/test_functions.py
import json import pytest from ..functions import ( doc_to_things, search, create, thing_to_doc, things_to_matches, find_matches_by_isbn, find_matches_by_identifiers, find_matches_by_title_and_publishers, massage_search_results, ) def same_dict(a, b): """ def same_dict(a:...
14,581
Python
.py
412
27.543689
93
0.543592
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
348
code.py
internetarchive_openlibrary/openlibrary/admin/code.py
import os import web from infogami.utils.view import render_template from openlibrary.core import admin from openlibrary.admin import utils app = web.auto_application() app.add_processor(utils.admin_processor) app.notfound = utils.notfound class home(app.page): # type: ignore[name-defined] path = "/admin/?" ...
796
Python
.py
21
33.857143
85
0.724771
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
349
utils.py
internetarchive_openlibrary/openlibrary/admin/utils.py
"""utils for admin application. """ import web from infogami.utils import delegate, features from infogami.utils.view import render_template def admin_processor(handler): """web.py application processor for enabling infogami and verifying admin permissions.""" delegate.initialize_context() delegate.cont...
748
Python
.py
20
33.2
93
0.736111
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
350
stats.py
internetarchive_openlibrary/openlibrary/admin/stats.py
""" Script to read out data from thingdb and put it in couch so that it can be queried by the /admin pages on openlibrary """ import os import logging import datetime import web import yaml from openlibrary.admin import numbers logger = logging.getLogger(__name__) web.config.debug = False class InvalidType(Type...
5,870
Python
.py
161
29.391304
112
0.632394
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
351
numbers.py
internetarchive_openlibrary/openlibrary/admin/numbers.py
""" List of functions that return various numbers which are stored in the admin database by the stats module. All functions prefixed with `admin_range__` will be run for each day and the result will be stored as the part after it. e.g. the result of admin_range__foo will be stored under the key `foo`. All functions p...
8,060
Python
.py
201
34.810945
98
0.65189
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
352
db.py
internetarchive_openlibrary/openlibrary/coverstore/db.py
import datetime import web from openlibrary.coverstore import config _categories = None _db = None def getdb(): global _db if _db is None: _db = web.database(**config.db_parameters) return _db def get_category_id(category): global _categories if _categories is None: _categorie...
3,426
Python
.py
124
20.298387
110
0.580409
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
353
config.py
internetarchive_openlibrary/openlibrary/coverstore/config.py
image_engine = "pil" image_sizes = {"S": (116, 58), "M": (180, 360), "L": (500, 500)} default_image = None data_root = None ol_url = "http://openlibrary.org/" # ids of the blocked covers # this is used to block covers when someone requests # an image to be blocked. blocked_covers: list[str] = [] def get(name, defa...
371
Python
.py
11
31.909091
64
0.687324
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
354
oldb.py
internetarchive_openlibrary/openlibrary/coverstore/oldb.py
"""Library to talk directly to OL database to avoid expensive API calls. """ import json import web from openlibrary.coverstore import config from openlibrary.utils import olmemcache __all__ = ["query", "get"] def is_supported(): return bool(config.get("ol_db_parameters")) _db = None def get_db(): glo...
1,932
Python
.py
62
24.967742
104
0.625541
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
355
archive.py
internetarchive_openlibrary/openlibrary/coverstore/archive.py
"""Utility to move files from local disk to zip files and update the paths in the db""" import glob import os import re import sys import subprocess import time import zipfile import web import internetarchive as ia from infogami.infobase import utils from openlibrary.coverstore import config, db from openlibrary.co...
18,877
Python
.py
436
32.944954
118
0.578684
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
356
code.py
internetarchive_openlibrary/openlibrary/coverstore/code.py
import array import datetime import io import json import logging import os import requests import web from PIL import Image, ImageDraw, ImageFont import textwrap from openlibrary.coverstore import config, db from openlibrary.coverstore.coverlib import read_file, read_image, save_image from openlibrary.coverstore....
17,063
Python
.py
460
27.236957
141
0.551373
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
357
utils.py
internetarchive_openlibrary/openlibrary/coverstore/utils.py
"""Utilities for coverstore""" import json import mimetypes import os import random import socket import string import requests import web from urllib.parse import urlsplit, urlunsplit, parse_qsl, unquote, unquote_plus # type: ignore[attr-defined] from urllib.parse import urlencode as real_urlencode from openlibrar...
4,821
Python
.py
145
25.489655
109
0.582399
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
358
__init__.py
internetarchive_openlibrary/openlibrary/coverstore/__init__.py
"""Image store to store book covers and author photos for the Open Library. """
80
Python
.py
2
39
75
0.75641
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
359
coverlib.py
internetarchive_openlibrary/openlibrary/coverstore/coverlib.py
"""Cover management.""" import datetime from logging import getLogger import os from io import BytesIO from PIL import Image import web from openlibrary.coverstore import config, db from openlibrary.coverstore.utils import random_string, rm_f logger = getLogger("openlibrary.coverstore.coverlib") __all__ = ["save_...
3,483
Python
.py
106
26.037736
92
0.588112
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
360
disk.py
internetarchive_openlibrary/openlibrary/coverstore/disk.py
import random import os import string chars = string.ascii_letters + string.digits def random_string(n): return "".join([random.choice(chars) for i in range(n)]) class Disk: """Disk interface to store files. >>> import os, string >>> _ = os.system("rm -rf test_disk") >>> disk = Disk("test_disk...
2,130
Python
.py
63
26.793651
68
0.611328
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
361
schema.py
internetarchive_openlibrary/openlibrary/coverstore/schema.py
"""Coverstore schema.""" from openlibrary.utils import schema def get_schema(engine='postgres'): s = schema.Schema() s.add_table( 'category', s.column('id', 'serial', primary_key=True), s.column('name', 'string'), ) s.add_table( 'cover', s.column('id', 'seria...
1,761
Python
.py
47
30.170213
83
0.583236
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
362
server.py
internetarchive_openlibrary/openlibrary/coverstore/server.py
#!/usr/bin/env python """coverstore server. """ import sys import yaml import web from openlibrary.coverstore import config, code, archive from openlibrary.utils.sentry import Sentry def runfcgi(func, addr=('localhost', 8000)): """Runs a WSGI function as a FastCGI pre-fork server.""" config = dict(web.confi...
1,292
Python
.py
40
27.225
85
0.656934
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
363
test_webapp.py
internetarchive_openlibrary/openlibrary/coverstore/tests/test_webapp.py
import json from os import system from os.path import abspath, dirname, join, pardir import pytest import web import urllib from openlibrary.coverstore import archive, code, config, coverlib, schema, utils static_dir = abspath(join(dirname(__file__), pardir, pardir, pardir, 'static')) @pytest.fixture(scope='module...
6,359
Python
.py
160
31.85
92
0.5919
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
364
test_coverstore.py
internetarchive_openlibrary/openlibrary/coverstore/tests/test_coverstore.py
import pytest import web from os.path import abspath, exists, join, dirname, pardir from openlibrary.coverstore import config, coverlib, utils static_dir = abspath(join(dirname(__file__), pardir, pardir, pardir, 'static')) image_formats = [ ['a', 'images/homesplash.jpg'], ['b', 'logos/logo-en.gif'], ['c'...
4,747
Python
.py
116
35.034483
87
0.618467
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
365
test_archive.py
internetarchive_openlibrary/openlibrary/coverstore/tests/test_archive.py
from .. import archive def test_get_filename(): # Basic usage assert archive.Batch.get_relpath("0008", "80") == "covers_0008/covers_0008_80" # Sizes assert ( archive.Batch.get_relpath("0008", "80", size="s") == "s_covers_0008/s_covers_0008_80" ) assert ( archive.Batch....
1,037
Python
.py
31
27.387097
82
0.593781
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
366
test_doctests.py
internetarchive_openlibrary/openlibrary/coverstore/tests/test_doctests.py
import doctest import pytest modules = [ 'openlibrary.coverstore.archive', 'openlibrary.coverstore.code', 'openlibrary.coverstore.db', 'openlibrary.coverstore.server', 'openlibrary.coverstore.utils', ] @pytest.mark.parametrize('module', modules) def test_doctest(module): mod = __import__(modu...
698
Python
.py
20
29.95
78
0.68
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
367
test_code.py
internetarchive_openlibrary/openlibrary/coverstore/tests/test_code.py
from .. import code from io import StringIO import web import datetime def test_tarindex_path(): assert code.get_tarindex_path(0, "") == "items/covers_0000/covers_0000_00.index" assert ( code.get_tarindex_path(0, "s") == "items/s_covers_0000/s_covers_0000_00.index" ) assert ( code.get_...
2,434
Python
.py
54
38.12963
87
0.617435
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
368
test_po_files.py
internetarchive_openlibrary/openlibrary/i18n/test_po_files.py
import os import pytest from babel.messages.pofile import read_po import xml.etree.ElementTree as ET from openlibrary.i18n import get_locales root = os.path.dirname(__file__) def trees_equal(el1: ET.Element, el2: ET.Element, error=True): """ Check if the tree data is the same >>> trees_equal(ET.fromstr...
2,723
Python
.py
69
32.855072
76
0.579007
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
369
__init__.py
internetarchive_openlibrary/openlibrary/i18n/__init__.py
import os import shutil import sys import subprocess from collections.abc import Iterator from io import BytesIO from pathlib import Path from datetime import datetime import web import babel from babel.support import Translations from babel.messages import Catalog, Message from babel.messages.pofile import read_po, ...
13,325
Python
.py
326
30.803681
111
0.584973
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
370
validators.py
internetarchive_openlibrary/openlibrary/i18n/validators.py
from itertools import groupby import re from babel.messages.catalog import TranslationError, Message, Catalog from babel.messages.checkers import python_format def validate(message: Message, catalog: Catalog) -> list[str]: errors = [f' {err}' for err in message.check(catalog)] if message.python_format and...
2,241
Python
.py
59
31.40678
87
0.513601
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
371
ol_infobase.py
internetarchive_openlibrary/openlibrary/plugins/ol_infobase.py
#!/usr/bin/env python """Open Library plugin for infobase. """ import datetime import json import logging import logging.config import os import re import sys import traceback import requests import web from infogami.infobase import cache, common, config, dbstore, server from openlibrary.plugins.upstream.utils impor...
17,209
Python
.py
474
28.259494
118
0.590879
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
372
filters.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/filters.py
""" Filters used to check if a certain statistic should be recorded """ import re import logging logger = logging.getLogger("openlibrary.stats_filters") import web from infogami import config def all(**params): "Returns true for all requests" return True def url(**params): logger.debug("Evaluate url ...
785
Python
.py
22
32.363636
83
0.727394
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
373
processors.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/processors.py
"""web.py application processors for Open Library. """ import re import web from openlibrary.accounts import get_current_user from openlibrary.core import cache from openlibrary.core.processors import ReadableUrlProcessor from openlibrary.plugins.openlibrary.home import caching_prethread from openlibrary.utils import...
3,656
Python
.py
94
28.531915
88
0.564726
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
374
opds.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/opds.py
""" OPDS helper class. A lightweight version of github.com/internetarchive/bookserver """ import lxml.etree as ET from infogami.infobase.utils import parse_datetime class OPDS: xmlns_atom = 'http://www.w3.org/2005/Atom' xmlns_dcterms = 'http://purl.org/dc/terms/' xmlns_opds = 'http://opds-spec.org/' ...
11,027
Python
.py
268
31.074627
86
0.504668
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
375
authors.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/authors.py
from infogami.utils import delegate from infogami.utils.view import render_template def setup(): pass class author(delegate.page): path = "/authors" def GET(self): return render_template("authors/index.html")
234
Python
.py
8
25.125
52
0.742081
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
376
bulk_tag.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/bulk_tag.py
from infogami.utils import delegate from openlibrary.core import stats from openlibrary.utils import uniq import web import json class bulk_tag_works(delegate.page): path = "/tags/bulk_tag_works" def POST(self): i = web.input(work_ids='', tags_to_add='', tags_to_remove='') works = i.work_id...
2,808
Python
.py
59
34.525424
86
0.559093
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
377
home.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/home.py
"""Controller for home page. """ import random import web import logging 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 from openlibrary.i18n im...
9,678
Python
.py
244
32.897541
88
0.63424
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
378
sentry.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/sentry.py
import infogami from infogami.utils import delegate from openlibrary.utils.sentry import Sentry, InfogamiSentryProcessor sentry: Sentry | None = None def setup(): global sentry sentry = Sentry(getattr(infogami.config, 'sentry', {})) if sentry.enabled: sentry.init() delegate.add_exception...
442
Python
.py
11
35.545455
77
0.758782
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
379
code.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/code.py
""" Open Library Plugin. """ from urllib.parse import parse_qs, urlparse, urlencode, urlunparse import requests import web import json import os import socket import random import datetime import logging from time import time import math import infogami from openlibrary.core import db from openlibrary.core.batch_impor...
41,921
Python
.py
1,123
28.162066
162
0.576301
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
380
infobase_hook.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/infobase_hook.py
"""Infobase hook for openlibrary. * Log all modified book pages as required for the search engine. """ from infogami.infobase import config from infogami.infobase.logger import Logger import datetime root = getattr(config, 'booklogroot', 'booklog') _logger = Logger(root) def hook(object): """ Add this ho...
727
Python
.py
20
31.95
66
0.69671
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
381
api.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/api.py
""" This file should be for internal APIs which Open Library requires for its experience. This does not include public facing APIs with LTS (long term support) """ import web import re import json import qrcode import io from collections import defaultdict from openlibrary.views.loanstats import get_trending_books fro...
22,401
Python
.py
561
29.128342
96
0.561576
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
382
status.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/status.py
from dataclasses import dataclass import datetime import functools from pathlib import Path import re import socket import sys from typing import Any from infogami import config from infogami.utils import delegate from infogami.utils.view import render_template, public from openlibrary.core import stats from openlibra...
3,176
Python
.py
96
26.760417
88
0.647367
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
383
events.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/events.py
"""Handling various events triggered by Open Library. """ from infogami.infobase import client import logging import web import eventer logger = logging.getLogger("openlibrary.events") def on_page_edit(page): pass class EditHook(client.hook): """Ugly Interface provided by Infobase to get event notificati...
739
Python
.py
20
32.45
73
0.712271
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
384
lists.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/lists.py
"""Lists implementation. """ from dataclasses import dataclass, field import json from urllib.parse import parse_qs import random from typing import Literal, cast import web from infogami.utils import delegate from infogami.utils.view import render_template, public, require_login from infogami.infobase import client,...
29,612
Python
.py
764
29.141361
98
0.569026
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
385
design.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/design.py
import web import logging from infogami.utils import delegate from infogami.utils.view import render_template, public logger = logging.getLogger("openlibrary.design") class home(delegate.page): path = "/developers/design" def GET(self): return render_template("design") def setup(): pass
315
Python
.py
11
25.181818
55
0.767677
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
386
borrow_home.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/borrow_home.py
""" Controllers for /borrow pages. These endpoints are largely deprecated, and only maintained for backwards compatibility. """ import web import datetime import json import eventer from infogami.utils import delegate from infogami.utils.view import render_template # used for its side effects from openlibrary.co...
2,567
Python
.py
70
31.471429
81
0.669769
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
387
support.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/support.py
import hashlib import web import logging from infogami import config from infogami.utils import delegate from infogami.utils.view import render_template from openlibrary import accounts from openlibrary.core import stats from openlibrary.core.cache import get_memcache from openlibrary.plugins.upstream.addbook import...
3,694
Python
.py
91
32.197802
89
0.617105
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
388
stats.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/stats.py
"""Hooks for collecting performance stats. """ import logging import os import re import sys import time import traceback from types import TracebackType from typing import Any from infogami.utils.app import find_page, find_view, find_mode from openlibrary.core import stats as graphite_stats import web from infogami ...
9,963
Python
.py
255
31.843137
88
0.628216
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
389
connection.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/connection.py
"""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.utils import stats import web import json import datetime from openlibrary.core import ia import logging logger = logging.getLogger("op...
22,354
Python
.py
505
33.570297
100
0.584549
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
390
schema.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/schema.py
"""OpenLibrary schema.""" from openlibrary.core.schema import get_schema if __name__ == "__main__": print(get_schema().sql())
132
Python
.py
4
30.5
46
0.666667
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
391
swagger.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/swagger.py
from infogami.utils import delegate from infogami.utils.view import render_template def setup(): pass class swagger(delegate.page): path = "/swagger/docs" def GET(self): return render_template("swagger/swaggerui.html")
244
Python
.py
8
26.375
56
0.748918
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
392
dev_instance.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/dev_instance.py
"""Special customizations for dev instance. This module is imported only if dev_instance is set to True in openlibrary config. """ import web import infogami from infogami.utils import delegate from openlibrary.core.task import oltask def setup(): setup_solr_updater() from openlibrary.catalog.utils import ...
5,866
Python
.py
138
34.985507
103
0.635915
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
393
conftest.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/tests/conftest.py
collect_ignore = ['test_listapi.py', 'test_ratingsapi.py'] def pytest_addoption(parser): parser.addoption("--server", default=None) parser.addoption("--username") parser.addoption("--password") def pytest_configure(config): print("pytest_configure", config.getvalue("server")) if config.getvalue...
363
Python
.py
9
35.666667
58
0.696275
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
394
test_listapi.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/tests/test_listapi.py
# from py.test import config import json import cookielib import urllib def pytest_funcarg__config(request): return request.config class ListAPI: def __init__(self, config): self.server = config.getvalue('server') self.username = config.getvalue("username") self.password = config.g...
3,650
Python
.py
104
27.682692
88
0.588336
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
395
test_ratingsapi.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/tests/test_ratingsapi.py
# from py.test import config import json import cookielib import urllib from openlibrary import accounts from openlibrary.core import models def pytest_funcarg__config(request): return request.config class RatingsAPI: def __init__(self, config): self.server = config.getvalue('server') self...
1,964
Python
.py
48
33.729167
88
0.650342
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
396
test_lists.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/tests/test_lists.py
import json from unittest.mock import patch import pytest from openlibrary.plugins.openlibrary.lists import ListRecord class TestListRecord: def test_from_input_no_data(self): with ( patch('web.input') as mock_web_input, patch('web.data') as mock_web_data, ): ...
3,676
Python
.py
98
24.734694
141
0.461603
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
397
test_stats.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/tests/test_stats.py
""" Tests the stats gathering systems. """ import calendar import datetime from .. import stats from openlibrary.core.admin import Stats class MockDoc(dict): def __init__(self, _id, *largs, **kargs): self.id = _id kargs['_key'] = _id super().__init__(*largs, **kargs) def __repr__(se...
2,760
Python
.py
63
38.68254
91
0.582991
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
398
test_home.py
internetarchive_openlibrary/openlibrary/plugins/openlibrary/tests/test_home.py
import datetime import web from openlibrary.core.admin import Stats from openlibrary.mocks.mock_infobase import MockSite from bs4 import BeautifulSoup from openlibrary.plugins.openlibrary import home class MockDoc(dict): def __init__(self, _id, *largs, **kargs): self.id = _id kargs['_key'] = _id...
6,240
Python
.py
155
28.722581
91
0.519637
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)
399
import_rdf.py
internetarchive_openlibrary/openlibrary/plugins/importapi/import_rdf.py
""" OL Import API RDF parser """ from openlibrary.plugins.importapi import import_edition_builder def parse_string(e, key): return (key, e.text) def parse_authors(e, key): s = './/{http://www.w3.org/1999/02/22-rdf-syntax-ns#}value' authors = [name.text for name in e.iterfind(s)] return (key, author...
3,039
Python
.py
73
34.931507
77
0.612542
internetarchive/openlibrary
5,078
1,311
956
AGPL-3.0
9/5/2024, 5:07:13 PM (Europe/Amsterdam)