id int64 | file_name string | file_path string | content string | size int64 | language string | extension string | total_lines int64 | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 | repo_name string | repo_stars int64 | repo_forks int64 | repo_open_issues int64 | repo_license string | repo_extraction_date string | exact_duplicates_stackv2 bool | exact_duplicates_redpajama bool | exact_duplicates_stackv1 bool | near_duplicates_stackv2 bool | near_duplicates_stackv1 bool | near_duplicates_redpajama bool | near_duplicates_codeparrot bool | near_duplicates_githubcode bool | exact_duplicates_githubcode bool | exact_duplicates_codeparrot bool | bandit string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | core_test.py | git-cola_git-cola/test/core_test.py | """Tests the cola.core module's unicode handling"""
from cola import core
from . import helper
def test_core_decode():
"""Test the core.decode function"""
filename = helper.fixture('unicode.txt')
expect = core.decode(core.encode('unicøde'))
actual = core.read(filename).strip()
assert expect == a... | 1,528 | Python | .py | 42 | 31.714286 | 53 | 0.689891 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:52Z",
"metrics": {
"/tmp/tmpml053r6z.py": {
"CONFIDENCE.HIGH": 8,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 8,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
1 | startup_test.py | git-cola_git-cola/test/startup_test.py | """Test Startup Dialog (git cola --prompt) Context Menu and related classes"""
from cola.widgets import startup
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def test_get_with_default_repo(app_context):
"""Test BuildItem::get for default repo"""
path = ... | 2,555 | Python | .py | 67 | 33.343284 | 78 | 0.703163 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:53Z",
"metrics": {
"/tmp/tmp1b9iprkl.py": {
"CONFIDENCE.HIGH": 26,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 26,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
2 | spellcheck_test.py | git-cola_git-cola/test/spellcheck_test.py | from cola import compat
from cola import spellcheck
from . import helper
def test_spellcheck_generator():
check = spellcheck.NorvigSpellCheck()
assert_spellcheck(check)
def test_spellcheck_unicode():
path = helper.fixture('unicode.txt')
check = spellcheck.NorvigSpellCheck(words=path)
assert_spe... | 474 | Python | .py | 14 | 29.5 | 51 | 0.752759 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:53Z",
"metrics": {
"/tmp/tmpm47a5hdn.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
3 | compat_test.py | git-cola_git-cola/test/compat_test.py | """Tests the compat module"""
import os
from cola import compat
def test_setenv():
"""Test the core.decode function"""
key = 'COLA_UNICODE_TEST'
value = '字龍'
compat.setenv(key, value)
assert key in os.environ
assert os.getenv(key)
compat.unsetenv(key)
assert key not in os.environ
... | 351 | Python | .py | 13 | 22.615385 | 39 | 0.690909 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:54Z",
"metrics": {
"/tmp/tmpzbnsua4e.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
4 | gitcfg_test.py | git-cola_git-cola/test/gitcfg_test.py | """Test the cola.gitcfg module."""
import pathlib
from . import helper
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def assert_color(context, expect, git_value, key='test', default=None):
"""Helper function for testing color values"""
helper.run_git('... | 4,587 | Python | .py | 103 | 40.126214 | 80 | 0.680189 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:54Z",
"metrics": {
"/tmp/tmpf3os3czt.py": {
"CONFIDENCE.HIGH": 22,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 22,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
5 | main_model_test.py | git-cola_git-cola/test/main_model_test.py | import os
import pytest
from cola import core
from cola import git
from cola.models import main
from cola.models.main import FETCH, FETCH_HEAD, PULL, PUSH
from . import helper
from .helper import app_context
from .helper import Mock
# prevent unused imports lint errors.
assert app_context is not None
REMOTE = 'se... | 7,183 | Python | .py | 222 | 26.689189 | 82 | 0.655522 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:54Z",
"metrics": {
"/tmp/tmpr3fdk162.py": {
"CONFIDENCE.HIGH": 53,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 53,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
6 | app_test.py | git-cola_git-cola/test/app_test.py | import argparse
from cola import app
def test_setup_environment():
# If the function doesn't throw an exception we are happy.
assert hasattr(app, 'setup_environment')
app.setup_environment()
def test_add_common_arguments():
# If the function doesn't throw an exception we are happy.
parser = arg... | 428 | Python | .py | 11 | 34.909091 | 62 | 0.75 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:55Z",
"metrics": {
"/tmp/tmpunaax2jv.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
7 | cmds_test.py | git-cola_git-cola/test/cmds_test.py | """Test the cmds module"""
from cola import cmds
from cola.compat import uchr
from .helper import Mock, patch
def test_Commit_strip_comments():
"""Ensure that commit messages are stripped of comments"""
msg = 'subject\n\n#comment\nbody'
expect = 'subject\n\nbody\n'
actual = cmds.Commit.strip_comment... | 7,046 | Python | .py | 170 | 36.582353 | 78 | 0.692105 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:55Z",
"metrics": {
"/tmp/tmpefqokizm.py": {
"CONFIDENCE.HIGH": 28,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 28,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
8 | display_test.py | git-cola_git-cola/test/display_test.py | from cola import display
def test_shorten_paths():
paths = (
'/usr/src/git-cola/src',
'/usr/src/example/src',
'/usr/src/super/lib/src',
'/usr/src/super/tools/src',
'/usr/src/super/example/src',
'/lib/src',
)
actual = display.shorten_paths(paths)
assert a... | 744 | Python | .py | 22 | 28.090909 | 50 | 0.615599 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:56Z",
"metrics": {
"/tmp/tmp4bbfyah4.py": {
"CONFIDENCE.HIGH": 7,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 7,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
9 | gitcmds_test.py | git-cola_git-cola/test/gitcmds_test.py | """Test the cola.gitcmds module"""
import os
from cola import core
from cola import gitcmds
from cola.widgets.remote import get_default_remote
from . import helper
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def test_currentbranch(app_context):
"""Test ... | 7,264 | Python | .py | 171 | 37.391813 | 88 | 0.66856 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:56Z",
"metrics": {
"/tmp/tmpr47lvf52.py": {
"CONFIDENCE.HIGH": 38,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 38,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
10 | gitops_test.py | git-cola_git-cola/test/gitops_test.py | """Tests basic git operations: commit, log, config"""
from . import helper
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def test_git_commit(app_context):
"""Test running 'git commit' via cola.git"""
helper.write_file('A', 'A')
helper.write_file('B'... | 816 | Python | .py | 21 | 34.809524 | 84 | 0.664549 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:57Z",
"metrics": {
"/tmp/tmpbvwld6ye.py": {
"CONFIDENCE.HIGH": 3,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 3,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
11 | branch_test.py | git-cola_git-cola/test/branch_test.py | """Tests related to the branches widget"""
from cola.widgets import branch
from .helper import Mock
def test_create_tree_entries():
names = [
'abc',
'cat/abc',
'cat/def',
'xyz/xyz',
]
root = branch.create_tree_entries(names)
expect = 3
actual = len(root.children)
... | 6,703 | Python | .py | 213 | 24.107981 | 84 | 0.569921 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:57Z",
"metrics": {
"/tmp/tmpl3_atqi6.py": {
"CONFIDENCE.HIGH": 39,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 39,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
12 | resources_test.py | git-cola_git-cola/test/resources_test.py | from cola import resources
from . import helper
from .helper import patch
@patch('cola.resources.compat')
@patch('cola.resources.get_prefix')
def test_command_unix(mock_prefix, mock_compat):
"""Test the behavior of resources.command() on unix platforms"""
mock_compat.WIN32 = False
mock_prefix.return_valu... | 1,146 | Python | .py | 28 | 36.892857 | 68 | 0.713255 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:58Z",
"metrics": {
"/tmp/tmpiste8vqm.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
13 | icons_test.py | git-cola_git-cola/test/icons_test.py | from cola import compat
from cola import core
from cola import icons
def test_from_filename_unicode():
filename = compat.uchr(0x400) + '.py'
expect = 'file-code.svg'
actual = icons.basename_from_filename(filename)
assert expect == actual
actual = icons.basename_from_filename(core.encode(filename)... | 350 | Python | .py | 10 | 31.3 | 64 | 0.738872 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:58Z",
"metrics": {
"/tmp/tmpmvbstr0i.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
14 | gravatar_test.py | git-cola_git-cola/test/gravatar_test.py | from cola import gravatar
from cola.compat import ustr
def test_url_for_email_():
email = 'email@example.com'
expect = (
'https://gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e?s=64'
+ r'&d=https%3A%2F%2Fgit-cola.github.io%2Fimages%2Fgit-64x64.jpg'
)
actual = gravatar.Gravatar.ur... | 407 | Python | .py | 11 | 32.181818 | 75 | 0.71066 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:59Z",
"metrics": {
"/tmp/tmpcji3q75s.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
15 | git_test.py | git-cola_git-cola/test/git_test.py | """Test the cola.git module"""
import os
import pathlib
from cola import git
from cola.git import STDOUT
from .helper import patch
# 16k+1 bytes to exhaust any output buffers.
BUFFER_SIZE = (16 * 1024) + 1
@patch('cola.git.is_git_dir')
def test_find_git_dir_None(is_git_dir):
paths = git.find_git_directory(Non... | 12,019 | Python | .py | 318 | 32.283019 | 84 | 0.640024 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:59Z",
"metrics": {
"/tmp/tmp2uwuf3eu.py": {
"CONFIDENCE.HIGH": 71,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 1,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 71,
"SEVERITY.MEDIUM": 1,
"SEVERITY.U... |
16 | settings_test.py | git-cola_git-cola/test/settings_test.py | """Test the cola.settings module"""
import os
import pytest
from cola.settings import Settings
from . import helper
@pytest.fixture(autouse=True)
def settings_fixture():
"""Provide Settings that save into a temporary location to all tests"""
filename = helper.tmp_path('settings')
Settings.config_path =... | 2,527 | Python | .py | 65 | 34.061538 | 75 | 0.691961 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:20:59Z",
"metrics": {
"/tmp/tmpch13d96v.py": {
"CONFIDENCE.HIGH": 9,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 5,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 9,
"SEVERITY.MEDIUM": 5,
"SEVERITY.UND... |
17 | utils_test.py | git-cola_git-cola/test/utils_test.py | """Tests the cola.utils module."""
import os
from cola import core
from cola import utils
def test_basename():
"""Test the utils.basename function."""
assert utils.basename('bar') == 'bar'
assert utils.basename('/bar') == 'bar'
assert utils.basename('/bar ') == 'bar '
assert utils.basename('foo/b... | 3,010 | Python | .py | 85 | 30.023529 | 67 | 0.630345 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:00Z",
"metrics": {
"/tmp/tmp44lz9p74.py": {
"CONFIDENCE.HIGH": 36,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 36,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
18 | browse_model_test.py | git-cola_git-cola/test/browse_model_test.py | """Test interfaces used by the browser (git cola browse)"""
from cola import core
from cola import gitcmds
from . import helper
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def test_stage_paths_untracked(app_context):
"""Test stage_paths() with an untrack... | 1,709 | Python | .py | 45 | 33.577778 | 59 | 0.697632 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:00Z",
"metrics": {
"/tmp/tmp5mmad9f_.py": {
"CONFIDENCE.HIGH": 10,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 10,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
20 | switcher_test.py | git-cola_git-cola/test/switcher_test.py | """Test Quick Switcher"""
from cola import icons
from cola.widgets import switcher
def test_switcher_item_with_only_key():
"""item text would be key by building item without name"""
key = 'item-key'
actual = switcher.switcher_item(key)
assert actual.key == key
assert actual.text() == key
def te... | 615 | Python | .py | 17 | 31.941176 | 68 | 0.688663 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:01Z",
"metrics": {
"/tmp/tmpn1ej2dfk.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
21 | helper.py | git-cola_git-cola/test/helper.py | import os
import shutil
import stat
import tempfile
from unittest.mock import Mock, patch
import pytest
from cola import core
from cola import git
from cola import gitcfg
from cola import gitcmds
from cola.models import main
# prevent unused imports lint errors.
assert patch is not None
def tmp_path(*paths):
... | 2,850 | Python | .py | 76 | 33.236842 | 88 | 0.691551 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:01Z",
"metrics": {
"/tmp/tmpgp2_xije.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
22 | i18n_test.py | git-cola_git-cola/test/i18n_test.py | """Tests for the i18n translation module"""
import os
import pytest
from cola import i18n
from cola.i18n import N_
from cola.compat import uchr
@pytest.fixture(autouse=True)
def i18n_context():
"""Perform cleanup/teardown of the i18n module"""
yield
i18n.uninstall()
def test_translates_noun():
"""... | 1,985 | Python | .py | 57 | 30.508772 | 70 | 0.678553 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:02Z",
"metrics": {
"/tmp/tmppor5tdjs.py": {
"CONFIDENCE.HIGH": 10,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 10,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
23 | stash_model_test.py | git-cola_git-cola/test/stash_model_test.py | from cola.models.stash import StashModel
from . import helper
from .helper import app_context
# Prevent unused imports lint errors.
assert app_context is not None
def test_stash_info_for_message_without_slash(app_context):
helper.commit_files()
helper.write_file('A', 'change')
helper.run_git('stash', '... | 1,525 | Python | .py | 39 | 33.974359 | 75 | 0.667346 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:02Z",
"metrics": {
"/tmp/tmp4ujvutaa.py": {
"CONFIDENCE.HIGH": 6,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 6,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
24 | models_selection_test.py | git-cola_git-cola/test/models_selection_test.py | from cola.models import selection
from .helper import Mock
def test_union():
t = Mock()
t.staged = ['a']
t.unmerged = ['a', 'b']
t.modified = ['b', 'a', 'c']
t.untracked = ['d']
expect = ['a', 'b', 'c', 'd']
actual = selection.union(t)
assert expect == actual
| 296 | Python | .py | 11 | 22.636364 | 33 | 0.558719 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:03Z",
"metrics": {
"/tmp/tmpd8o8eofd.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
25 | diffparse_test.py | git-cola_git-cola/test/diffparse_test.py | """Tests for the diffparse module"""
import pytest
from cola import core
from cola import diffparse
from . import helper
class DiffLinesTestData:
"""Test data used by DiffLines tests"""
def __init__(self):
self.parser = diffparse.DiffLines()
fixture_path = helper.fixture('diff.txt')
... | 10,053 | Python | .py | 297 | 28.592593 | 88 | 0.598367 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:03Z",
"metrics": {
"/tmp/tmpa8x925p4.py": {
"CONFIDENCE.HIGH": 104,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 104,
"SEVERITY.MEDIUM": 0,
"SEVERITY... |
26 | textwrap_test.py | git-cola_git-cola/test/textwrap_test.py | """Test the textwrap module"""
import pytest
from cola import textwrap
class WordWrapDefaults:
def __init__(self):
self.tabwidth = 8
self.limit = None
def wrap(self, text, break_on_hyphens=True):
return textwrap.word_wrap(
text, self.tabwidth, self.limit, break_on_hyphens... | 4,877 | Python | .py | 158 | 26.772152 | 78 | 0.669455 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:04Z",
"metrics": {
"/tmp/tmpuxqs1616.py": {
"CONFIDENCE.HIGH": 30,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 30,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
27 | _activate_cola.py | git-cola_git-cola/bin/_activate_cola.py | # Developer wrapper script helper functions
import configparser
import datetime
import os
import sys
def activate():
"""Activate the cola development environment"""
initialize_python()
initialize_version()
def get_prefix():
"""Return the path to the source tree"""
realpath = os.path.abspath(os.p... | 3,910 | Python | .py | 104 | 31.288462 | 85 | 0.651772 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:04Z",
"metrics": {
"/tmp/tmpod3gwdrf.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 2,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
30 | conf.py | git-cola_git-cola/docs/conf.py | import os
import sys
try:
import furo
except ImportError:
furo = None
try:
import sphinx_rtd_theme
except ImportError:
sphinx_rtd_theme = None
try:
import rst.linker as rst_linker
except ImportError:
rst_linker = None
# Add the source tree and extras/ to sys.path.
srcdir = os.path.dirname(os.p... | 3,186 | Python | .py | 93 | 29.451613 | 87 | 0.658862 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:05Z",
"metrics": {
"/tmp/tmp2o13xmry.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
39 | cmds.py | git-cola_git-cola/cola/cmds.py | """Editor commands"""
import os
import re
import sys
from fnmatch import fnmatch
from io import StringIO
try:
from send2trash import send2trash
except ImportError:
send2trash = None
from . import compat
from . import core
from . import gitcmds
from . import icons
from . import resources
from . import textwrap... | 94,958 | Python | .py | 2,476 | 29.057754 | 87 | 0.585685 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:09Z",
"metrics": {
"/tmp/tmpoa6hyg28.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
45 | git.py | git-cola_git-cola/cola/git.py | from functools import partial
import errno
import os
from os.path import join
import subprocess
import threading
import time
from . import core
from .compat import int_types
from .compat import ustr
from .compat import WIN32
from .decorators import memoize
from .interaction import Interaction
GIT_COLA_TRACE = core.g... | 14,698 | Python | .py | 383 | 28.284595 | 87 | 0.56887 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:11Z",
"metrics": {
"/tmp/tmpi6tqr0rc.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
50 | utils.py | git-cola_git-cola/cola/utils.py | """Miscellaneous utility functions"""
import copy
import os
import re
import shlex
import sys
import tempfile
import time
import traceback
from . import core
from . import compat
def asint(obj, default=0):
"""Make any value into an int, even if the cast fails"""
try:
value = int(obj)
except (Type... | 10,897 | Python | .py | 327 | 27.033639 | 84 | 0.619166 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:14Z",
"metrics": {
"/tmp/tmpmi7kbkgc.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 1,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
51 | core.py | git-cola_git-cola/cola/core.py | """This module provides core functions for handling Unicode and Unix quirks
The @interruptable functions retry when system calls are interrupted,
e.g. when python raises an IOError or OSError with errno == EINTR.
"""
import ctypes
import functools
import itertools
import mimetypes
import os
import platform
import subp... | 16,154 | Python | .py | 431 | 31.672854 | 88 | 0.677287 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:14Z",
"metrics": {
"/tmp/tmp82or4jw6.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 2,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
56 | inotify.py | git-cola_git-cola/cola/inotify.py | import ctypes
import ctypes.util
import errno
import os
# constant from Linux include/uapi/linux/limits.h
NAME_MAX = 255
# constants from Linux include/uapi/linux/inotify.h
IN_MODIFY = 0x00000002
IN_ATTRIB = 0x00000004
IN_CLOSE_WRITE = 0x00000008
IN_MOVED_FROM = 0x00000040
IN_MOVED_TO = 0x00000080
IN_CREATE = 0x00000... | 2,195 | Python | .py | 66 | 28.5 | 70 | 0.683736 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:17Z",
"metrics": {
"/tmp/tmpsx8mmv0f.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
59 | gravatar.py | git-cola_git-cola/cola/gravatar.py | import time
import hashlib
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from qtpy import QtNetwork
from . import core
from . import icons
from . import qtutils
from .compat import parse
from .models import prefs
from .widgets import defs
class Gravatar:
@staticmethod
def url_for... | 5,301 | Python | .py | 127 | 33.062992 | 83 | 0.639379 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:18Z",
"metrics": {
"/tmp/tmpxwjchs4n.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 2,
"SEVERITY.UND... |
67 | fsmonitor.py | git-cola_git-cola/cola/fsmonitor.py | # Copyright (C) 2008-2024 David Aguilar
# Copyright (C) 2015 Daniel Harding
"""Filesystem monitor for Linux and Windows
Linux monitoring uses using inotify.
Windows monitoring uses pywin32 and the ReadDirectoryChanges function.
"""
import errno
import os
import os.path
import select
from threading import Lock
from q... | 19,921 | Python | .py | 487 | 26.431211 | 88 | 0.507382 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:22Z",
"metrics": {
"/tmp/tmprsahi_ef.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
81 | highlighter.py | git-cola_git-cola/cola/widgets/highlighter.py | from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
have_pygments = True
try:
from pygments.styles import get_style_by_name
from pygments import lex
from pygments.util import ClassNotFound
from pygments.lexers import get_lexer_for_filename
except ImportError:
have_pygments = F... | 3,268 | Python | .py | 90 | 27.2 | 72 | 0.606646 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:28Z",
"metrics": {
"/tmp/tmp795x5yjq.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
93 | status.py | git-cola_git-cola/cola/widgets/status.py | import itertools
import os
from functools import partial
from qtpy.QtCore import Qt
from qtpy import QtCore
from qtpy import QtWidgets
from ..i18n import N_
from ..models import prefs
from ..models import selection
from ..widgets import gitignore
from ..widgets import standard
from ..qtutils import get
from ..setting... | 61,277 | Python | .py | 1,448 | 31.953729 | 88 | 0.609709 | git-cola/git-cola | 2,239 | 455 | 69 | GPL-2.0 | 9/5/2024, 5:06:50 PM (Europe/Amsterdam) | false | false | false | false | false | false | true | true | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:35Z",
"metrics": {
"/tmp/tmpbq5_tn4r.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
189 | config.py | internetarchive_openlibrary/openlibrary/config.py | """Utility for loading config file.
"""
import os
import sys
import yaml
import infogami
from infogami import config
from infogami.infobase import server
runtime_config = {}
def load(config_file):
"""legacy function to load openlibary config.
The loaded config will be available via runtime_config var in th... | 1,698 | Python | .py | 44 | 33.409091 | 89 | 0.713764 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:50Z",
"metrics": {
"/tmp/tmp42mbdokw.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
193 | book_providers.py | internetarchive_openlibrary/openlibrary/book_providers.py | from dataclasses import dataclass
import logging
from collections.abc import Callable, Iterator
from typing import TypedDict, Literal, cast, TypeVar, Generic
from urllib import parse
import web
from web import uniq
from web.template import TemplateResult
from openlibrary.app import render_template
from openlibrary.pl... | 22,287 | Python | .py | 568 | 30.105634 | 103 | 0.607057 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:53Z",
"metrics": {
"/tmp/tmp90m9fcgm.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
195 | mapreduce.py | internetarchive_openlibrary/openlibrary/data/mapreduce.py | """Simple library to process large datasets using map-reduce.
This works as follows:
* Takes an iterator of key-value pairs as input
* Applies the map function for each key-value pair. The map function does the
required processing to yield zero or more key-value pairs.
* The result of map are stored in the disk in ... | 4,222 | Python | .py | 97 | 35.773196 | 133 | 0.642997 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:54Z",
"metrics": {
"/tmp/tmpunuw1ng7.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 1,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 1,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
199 | dump.py | internetarchive_openlibrary/openlibrary/data/dump.py | """Library for generating and processing Open Library data dumps.
Glossary:
* dump - Dump of latest revisions of all documents.
* cdump - Complete dump. Dump of all revisions of all documents.
* idump - Incremental dump. Dump of all revisions created in the given day.
"""
import gzip
import itertools
import json
imp... | 11,275 | Python | .py | 293 | 31.580205 | 87 | 0.592538 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:55Z",
"metrics": {
"/tmp/tmpcs6_jjxh.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 1,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 1,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
202 | utils.py | internetarchive_openlibrary/openlibrary/solr/utils.py | from dataclasses import dataclass, field
import json
import logging
import httpx
from httpx import HTTPError, HTTPStatusError, TimeoutException
from openlibrary import config
from openlibrary.solr.solr_types import SolrDocument
from openlibrary.utils.retry import MaxRetriesExceeded, RetryStrategy
logger = logging.ge... | 6,011 | Python | .py | 162 | 28.697531 | 86 | 0.601723 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:57Z",
"metrics": {
"/tmp/tmp1mfpcxcw.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
203 | types_generator.py | internetarchive_openlibrary/openlibrary/solr/types_generator.py | #!/usr/bin/env python
import os
root = os.path.dirname(__file__)
OVERRIDES = {
'type': "Literal['work', 'author', 'subject']",
'public_scan_b': 'Optional[bool]',
'printdisabled_s': 'Optional[str]',
'lending_edition_s': 'Optional[str]',
'ia_collection_s': 'Optional[str]',
'ebook_count_i': 'Optio... | 2,981 | Python | .py | 81 | 27.111111 | 80 | 0.539528 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:57Z",
"metrics": {
"/tmp/tmp54ydm1ri.py": {
"CONFIDENCE.HIGH": 3,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 2,
"SEVERITY.UND... |
204 | update.py | internetarchive_openlibrary/openlibrary/solr/update.py | import functools
import logging
from pathlib import Path
from typing import Literal, cast
import aiofiles
import json
import web
from openlibrary.catalog.utils.query import set_query_host
from openlibrary.solr.data_provider import (
get_data_provider,
DataProvider,
ExternalDataProvider,
)
from openlibrar... | 7,160 | Python | .py | 174 | 33.241379 | 117 | 0.645941 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:58Z",
"metrics": {
"/tmp/tmpigo5bocf.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
205 | data_provider.py | internetarchive_openlibrary/openlibrary/solr/data_provider.py | """Module to provide data for solr indexer.
This module has all the logic for querying different sources for getting the
data required for solr.
Multiple data providers are supported, each is good for different use case.
"""
import asyncio
import itertools
import logging
import re
from typing import Optional, TypedD... | 18,714 | Python | .py | 458 | 31.360262 | 99 | 0.580283 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:58Z",
"metrics": {
"/tmp/tmpd7rtkfw0.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 5,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 5,
"SEVERITY.UND... |
206 | author.py | internetarchive_openlibrary/openlibrary/solr/updater/author.py | from typing import cast
import typing
import httpx
from openlibrary.solr.solr_types import SolrDocument
from openlibrary.solr.updater.abstract import AbstractSolrBuilder, AbstractSolrUpdater
from openlibrary.solr.utils import SolrUpdateRequest, get_solr_base_url
from openlibrary.solr.data_provider import WorkReadingLog... | 4,951 | Python | .py | 122 | 30.47541 | 88 | 0.569288 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:59Z",
"metrics": {
"/tmp/tmprodga8gj.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
207 | edition.py | internetarchive_openlibrary/openlibrary/solr/updater/edition.py | from functools import cached_property
import logging
import re
from typing import TYPE_CHECKING, cast
import requests
import openlibrary.book_providers as bp
from openlibrary.solr.solr_types import SolrDocument
from openlibrary.solr.updater.abstract import AbstractSolrBuilder, AbstractSolrUpdater
from openlibrary.solr... | 11,402 | Python | .py | 292 | 28.705479 | 97 | 0.549358 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:21:59Z",
"metrics": {
"/tmp/tmpcx2022sm.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
208 | work.py | internetarchive_openlibrary/openlibrary/solr/updater/work.py | from collections import defaultdict
from collections.abc import Iterable
import datetime
from functools import cached_property
import itertools
import logging
from math import ceil
import re
from statistics import median
import time
from typing import Optional, TypedDict, cast
from openlibrary.core import helpers as h
... | 23,289 | Python | .py | 587 | 29.529813 | 98 | 0.562085 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:00Z",
"metrics": {
"/tmp/tmp9itt39bi.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
211 | get_ia.py | internetarchive_openlibrary/openlibrary/catalog/get_ia.py | import requests
from infogami import config
from lxml import etree
from time import sleep
from openlibrary.catalog.marc.marc_binary import MarcBinary
from openlibrary.catalog.marc.marc_xml import MarcXml
from openlibrary.core import ia
import lxml.etree
IA_BASE_URL = config.get('ia_base_url')
IA_DOWNLOAD_URL = f'{I... | 3,774 | Python | .py | 90 | 34.677778 | 114 | 0.651842 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:01Z",
"metrics": {
"/tmp/tmp2bmqtl18.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 3,
"SEVERITY.MEDIUM": 2,
"SEVERITY.UND... |
212 | match.py | internetarchive_openlibrary/openlibrary/catalog/add_book/match.py | import re
import unicodedata
import web
# fields needed for matching:
# title, subtitle, isbn, publish_country, lccn, publishers, publish_date, number_of_pages, authors
re_amazon_title_paren = re.compile(r'^(.*) \([^)]+?\)$')
re_brackets = re.compile(r'^(.+)\[.*?\]$')
re_whitespace_and_punct = re.compile(r'[-\s,;:.]+... | 15,119 | Python | .py | 394 | 31.147208 | 126 | 0.59828 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:02Z",
"metrics": {
"/tmp/tmpwjbq8vzc.py": {
"CONFIDENCE.HIGH": 3,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 3,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
213 | __init__.py | internetarchive_openlibrary/openlibrary/catalog/add_book/__init__.py | """Module to load books into Open Library.
This is used to load books from various MARC sources, including
Internet Archive.
For loading a book, the available metadata is compiled as a dict,
called a record internally. Here is a sample record:
{
"title": "The Adventures of Tom Sawyer",
"source_re... | 32,077 | Python | .py | 833 | 31.103241 | 118 | 0.618973 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:02Z",
"metrics": {
"/tmp/tmpv6wzzhzv.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
214 | load_book.py | internetarchive_openlibrary/openlibrary/catalog/add_book/load_book.py | from typing import TYPE_CHECKING, Any, Final
import web
from openlibrary.catalog.utils import flip_name, author_dates_match, key_int
from openlibrary.core.helpers import extract_year
if TYPE_CHECKING:
from openlibrary.plugins.upstream.models import Author
# Sort by descending length to remove the _longest_ match... | 9,244 | Python | .py | 265 | 27.211321 | 97 | 0.5717 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:03Z",
"metrics": {
"/tmp/tmpfm62vc_3.py": {
"CONFIDENCE.HIGH": 5,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 5,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
216 | test_match.py | internetarchive_openlibrary/openlibrary/catalog/add_book/tests/test_match.py | import pytest
from copy import deepcopy
from openlibrary.catalog.add_book import load
from openlibrary.catalog.add_book.match import (
THRESHOLD,
add_db_name,
build_titles,
compare_authors,
compare_publisher,
editions_match,
expand_record,
normalize,
mk_norm,
threshold_match,
)... | 14,923 | Python | .py | 374 | 30.010695 | 93 | 0.559343 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:04Z",
"metrics": {
"/tmp/tmppv57t94j.py": {
"CONFIDENCE.HIGH": 56,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 56,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
217 | test_load_book.py | internetarchive_openlibrary/openlibrary/catalog/add_book/tests/test_load_book.py | import pytest
from openlibrary.catalog.add_book import load_book
from openlibrary.catalog.add_book.load_book import (
find_entity,
import_author,
build_query,
InvalidLanguage,
remove_author_honorifics,
)
from openlibrary.core.models import Author
@pytest.fixture
def new_import(monkeypatch):
mo... | 11,307 | Python | .py | 287 | 29.916376 | 93 | 0.56219 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:04Z",
"metrics": {
"/tmp/tmpe319qnxc.py": {
"CONFIDENCE.HIGH": 23,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 23,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
218 | test_add_book.py | internetarchive_openlibrary/openlibrary/catalog/add_book/tests/test_add_book.py | import os
import pytest
from datetime import datetime
from infogami.infobase.client import Nothing
from infogami.infobase.core import Text
from openlibrary.catalog import add_book
from openlibrary.catalog.add_book import (
build_pool,
editions_matched,
find_match,
IndependentlyPublished,
isbns_fro... | 59,742 | Python | .py | 1,614 | 27.512392 | 106 | 0.529031 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:05Z",
"metrics": {
"/tmp/tmpqwya0ikd.py": {
"CONFIDENCE.HIGH": 199,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 199,
"SEVERITY.MEDIUM": 0,
"SEVERITY... |
219 | edit.py | internetarchive_openlibrary/openlibrary/catalog/utils/edit.py | import re
import requests
import web
from openlibrary.catalog.utils.query import get_mc
from openlibrary.api import unmarshal
from time import sleep
re_meta_mrc = re.compile('([^/]+)_(meta|marc).(mrc|xml)')
re_skip = re.compile(r'\b([A-Z]|Co|Dr|Jr|Capt|Mr|Mrs|Ms|Prof|Rev|Revd|Hon)\.$')
db_amazon = web.database(dbn='p... | 3,388 | Python | .py | 91 | 30.263736 | 85 | 0.582468 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:06Z",
"metrics": {
"/tmp/tmpg2t0y6ze.py": {
"CONFIDENCE.HIGH": 3,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 3,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
220 | __init__.py | internetarchive_openlibrary/openlibrary/catalog/utils/__init__.py | import datetime
import re
from typing import TYPE_CHECKING
import web
from unicodedata import normalize
if TYPE_CHECKING:
from openlibrary.plugins.upstream.models import Author
EARLIEST_PUBLISH_YEAR_FOR_BOOKSELLERS = 1400
BOOKSELLERS_WITH_ADDITIONAL_VALIDATION = ['amazon', 'bwb']
def cmp(x, y):
return (x >... | 12,779 | Python | .py | 333 | 31.531532 | 130 | 0.599158 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:06Z",
"metrics": {
"/tmp/tmp8saaw8e6.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
221 | query.py | internetarchive_openlibrary/openlibrary/catalog/utils/query.py | import requests
import web
import json
from time import sleep
import urllib
import sys
query_host = 'openlibrary.org'
def urlopen(url, data=None):
version = "%s.%s.%s" % sys.version_info[:3]
user_agent = f'Mozilla/5.0 (openlibrary; {__name__}) Python/{version}'
headers = {'User-Agent': user_agent}
... | 4,179 | Python | .py | 145 | 20.862069 | 84 | 0.542407 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:07Z",
"metrics": {
"/tmp/tmpl5rh2z5m.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
222 | marc_binary.py | internetarchive_openlibrary/openlibrary/catalog/marc/marc_binary.py | from pymarc import MARC8ToUnicode
from unicodedata import normalize
from collections.abc import Iterator
from openlibrary.catalog.marc import mnemonics
from openlibrary.catalog.marc.marc_base import (
MarcBase,
MarcFieldBase,
MarcException,
BadMARC,
)
marc8 = MARC8ToUnicode(quiet=True)
class BadLen... | 6,266 | Python | .py | 162 | 28.839506 | 103 | 0.561678 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:07Z",
"metrics": {
"/tmp/tmph1rlubge.py": {
"CONFIDENCE.HIGH": 5,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 5,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
223 | marc_base.py | internetarchive_openlibrary/openlibrary/catalog/marc/marc_base.py | import re
from abc import abstractmethod
from collections import defaultdict
from collections.abc import Iterator
re_isbn = re.compile(r'([^ ()]+[\dX])(?: \((?:v\. (\d+)(?: : )?)?(.*)\))?')
# handle ISBN like: 1402563884c$26.95
re_isbn_and_price = re.compile(r'^([-\d]+X?)c\$[\d.]+$')
class MarcException(Exception):
... | 3,200 | Python | .py | 80 | 31.725 | 88 | 0.597805 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:08Z",
"metrics": {
"/tmp/tmpiq4setbl.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
225 | html.py | internetarchive_openlibrary/openlibrary/catalog/marc/html.py | import re
from pymarc.record import Record
trans = {'&': '&', '<': '<', '>': '>', '\n': '<br>', '\x1b': '<b>[esc]</b>'}
re_html_replace = re.compile('([&<>\n\x1b])')
def esc(s):
return re_html_replace.sub(lambda m: trans[m.group(1)], s)
def subfields(line):
if isinstance(line, str):
retu... | 924 | Python | .py | 26 | 28.038462 | 86 | 0.514061 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:08Z",
"metrics": {
"/tmp/tmpvjeswgvb.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
226 | parse.py | internetarchive_openlibrary/openlibrary/catalog/marc/parse.py | import logging
import re
from typing import Any
from collections.abc import Callable
from openlibrary.catalog.marc.get_subjects import subjects_for_work
from openlibrary.catalog.marc.marc_base import (
MarcBase,
MarcFieldBase,
BadMARC,
NoTitle,
MarcException,
)
from openlibrary.catalog.utils import... | 26,720 | Python | .py | 667 | 31.923538 | 119 | 0.573283 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:09Z",
"metrics": {
"/tmp/tmpr1l2o1b8.py": {
"CONFIDENCE.HIGH": 5,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 5,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
227 | mnemonics.py | internetarchive_openlibrary/openlibrary/catalog/marc/mnemonics.py | # read MARC mnemonics
# result is in MARC8 and still needs to be converted to Unicode
import re
re_brace = re.compile(b'(\\{.+?\\})')
mapping = {
b'{00}': b'\x00',
b'{01}': b'\x01',
b'{02}': b'\x02',
b'{03}': b'\x03',
b'{04}': b'\x04',
b'{05}': b'\x05',
b'{06}': b'\x06',
b'{07}': b'\x... | 16,118 | Python | .py | 710 | 17.678873 | 77 | 0.369481 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:09Z",
"metrics": {
"/tmp/tmpi8urbwsz.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
228 | marc_xml.py | internetarchive_openlibrary/openlibrary/catalog/marc/marc_xml.py | from lxml import etree
from unicodedata import normalize
from collections.abc import Iterator
from openlibrary.catalog.marc.marc_base import MarcBase, MarcFieldBase, MarcException
data_tag = '{http://www.loc.gov/MARC21/slim}datafield'
control_tag = '{http://www.loc.gov/MARC21/slim}controlfield'
subfield_tag = '{http:... | 3,278 | Python | .py | 83 | 30.746988 | 85 | 0.600567 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:10Z",
"metrics": {
"/tmp/tmpwdh50kq_.py": {
"CONFIDENCE.HIGH": 6,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 6,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
229 | test_marc.py | internetarchive_openlibrary/openlibrary/catalog/marc/tests/test_marc.py | from openlibrary.catalog.marc.get_subjects import subjects_for_work
from openlibrary.catalog.marc.marc_base import MarcBase
from openlibrary.catalog.marc.parse import read_isbn, read_pagination, read_title
class MockField:
def __init__(self, subfields):
self.subfield_sequence = subfields
self.cont... | 6,578 | Python | .py | 180 | 25.644444 | 122 | 0.500314 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:10Z",
"metrics": {
"/tmp/tmp4q2ofv8a.py": {
"CONFIDENCE.HIGH": 7,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 7,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
230 | test_get_subjects.py | internetarchive_openlibrary/openlibrary/catalog/marc/tests/test_get_subjects.py | from openlibrary.catalog.marc.marc_xml import MarcXml
from openlibrary.catalog.marc.marc_binary import MarcBinary
from openlibrary.catalog.marc.get_subjects import four_types, read_subjects
from lxml import etree
from pathlib import Path
import pytest
import lxml.etree
xml_samples = [
('bijouorannualofl1828cole', ... | 8,063 | Python | .py | 259 | 21.467181 | 88 | 0.481272 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:11Z",
"metrics": {
"/tmp/tmpysyeublc.py": {
"CONFIDENCE.HIGH": 7,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 6,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
231 | test_mnemonics.py | internetarchive_openlibrary/openlibrary/catalog/marc/tests/test_mnemonics.py | from openlibrary.catalog.marc.mnemonics import read
def test_read_conversion_to_marc8():
input_ = (
b'Tha{mllhring}{macr}alib{macr}i, {mllhring}Abd al-Malik ibn Mu{dotb}hammad,'
)
output = b'Tha\xb0\xe5alib\xe5i, \xb0Abd al-Malik ibn Mu\xf2hammad,'
assert read(input_) == output
def test_read... | 485 | Python | .py | 10 | 43.9 | 116 | 0.707006 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:11Z",
"metrics": {
"/tmp/tmpfzf4vkce.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
232 | test_marc_html.py | internetarchive_openlibrary/openlibrary/catalog/marc/tests/test_marc_html.py | from pathlib import Path
from openlibrary.catalog.marc.html import html_record
TEST_DATA = Path(__file__).with_name('test_data') / 'bin_input'
def test_html_line_marc8():
filepath = TEST_DATA / 'uoft_4351105_1626.mrc'
expected_utf8 = (
'<b>700</b> <code>1 <b>$a</b>Ovsi︠a︡nnikov, Mikhail Fedotovich.... | 453 | Python | .py | 11 | 36.545455 | 84 | 0.679724 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:12Z",
"metrics": {
"/tmp/tmp1p4f70ag.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
233 | test_marc_binary.py | internetarchive_openlibrary/openlibrary/catalog/marc/tests/test_marc_binary.py | from pathlib import Path
from openlibrary.catalog.marc.marc_binary import BinaryDataField, MarcBinary
TEST_DATA = Path(__file__).with_name('test_data') / 'bin_input'
class MockMARC:
def __init__(self, encoding):
"""
:param encoding str: 'utf8' or 'marc8'
"""
self.encoding = encodi... | 2,631 | Python | .py | 65 | 32.4 | 88 | 0.607843 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:12Z",
"metrics": {
"/tmp/tmpqcpv6emz.py": {
"CONFIDENCE.HIGH": 16,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 16,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
234 | test_parse.py | internetarchive_openlibrary/openlibrary/catalog/marc/tests/test_parse.py | import json
import pytest
from openlibrary.catalog.marc.parse import (
read_author_person,
read_edition,
NoTitle,
SeeAlsoAsTitle,
)
from openlibrary.catalog.marc.marc_binary import MarcBinary
from openlibrary.catalog.marc.marc_xml import DataField, MarcXml
from lxml import etree
from pathlib import Pat... | 7,077 | Python | .py | 177 | 32.723164 | 109 | 0.64541 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:13Z",
"metrics": {
"/tmp/tmpf7bdmwuk.py": {
"CONFIDENCE.HIGH": 21,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 19,
"SEVERITY.MEDIUM": 2,
"SEVERITY.U... |
237 | test_events.py | internetarchive_openlibrary/openlibrary/olbase/tests/test_events.py | from .. import events
class TestMemcacheInvalidater:
def test_seed_to_key(self):
m = events.MemcacheInvalidater()
assert m.seed_to_key({"key": "/books/OL1M"}) == "/books/OL1M"
assert m.seed_to_key("subject:love") == "/subjects/love"
assert m.seed_to_key("place:san_francisco") == "/... | 3,137 | Python | .py | 85 | 23.364706 | 86 | 0.431624 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:14Z",
"metrics": {
"/tmp/tmpawlg6o7r.py": {
"CONFIDENCE.HIGH": 10,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 10,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
238 | test_ol_infobase.py | internetarchive_openlibrary/openlibrary/olbase/tests/test_ol_infobase.py | from openlibrary.plugins.ol_infobase import OLIndexer
class TestOLIndexer:
def test_expand_isbns(self):
indexer = OLIndexer()
isbn_10 = ['123456789X']
isbn_13 = ['9781234567897']
both = isbn_10 + isbn_13
assert indexer.expand_isbns([]) == []
assert sorted(indexer.ex... | 468 | Python | .py | 11 | 35.181818 | 60 | 0.650549 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:14Z",
"metrics": {
"/tmp/tmpa9rwvboh.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
239 | showmarc.py | internetarchive_openlibrary/openlibrary/views/showmarc.py | """
Hook to show MARC or other source record details in Open Library.
"""
from .. import app
import web
import re
import requests
class old_show_marc(app.view):
path = "/show-marc/(.*)"
def GET(self, param):
raise web.seeother('/show-records/' + param)
class show_ia(app.view):
path = "/show-... | 4,403 | Python | .py | 115 | 28.252174 | 93 | 0.554013 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:15Z",
"metrics": {
"/tmp/tmpu1i9olj6.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 3,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 3,
"SEVERITY.UND... |
242 | compress.py | internetarchive_openlibrary/openlibrary/utils/compress.py | # incremental zlib compression, written by solrize, August 2009
import zlib
__doc__ = """
Compressor object for medium-sized, statistically-similar strings.
The idea is that you have a lot of moderate-sized strings (short email
messages or the like) that you would like to compress independently,
for storage in a look... | 3,422 | Python | .py | 74 | 41.094595 | 77 | 0.70447 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:16Z",
"metrics": {
"/tmp/tmp79q7x_h_.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
250 | __init__.py | internetarchive_openlibrary/openlibrary/utils/__init__.py | """Generic utilities"""
from enum import Enum
import re
from subprocess import CalledProcessError, run
from typing import TypeVar, Literal
from collections.abc import Iterable, Callable
to_drop = set(''';/?:@&=+$,<>#%"{}|\\^[]`\n\r''')
def str_to_key(s: str) -> str:
"""
>>> str_to_key("?H$e##l{o}[0] -world!... | 5,931 | Python | .py | 191 | 25.120419 | 83 | 0.555595 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:20Z",
"metrics": {
"/tmp/tmpuubocex6.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
253 | bulkimport.py | internetarchive_openlibrary/openlibrary/utils/bulkimport.py | """Utility to bulk import documents into Open Library database without
going through infobase API.
"""
import json
import os
import web
import datetime
from collections import defaultdict
class DocumentLoader:
def __init__(self, **params):
params = params.copy()
params.setdefault('dbn', 'postgres... | 16,125 | Python | .py | 414 | 26.898551 | 109 | 0.521937 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:21Z",
"metrics": {
"/tmp/tmpipsjiq_c.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 1,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 1,
"SEVERITY.UND... |
256 | lcc.py | internetarchive_openlibrary/openlibrary/utils/lcc.py | """
Crash course Library of Congress Classification (LCC)
Examples:
- HB1951 .R64 1995
- DP402.C8 O46 1995
- CS879 .R3 1995
- NC248.S22 A4 1992
- TJ563 .P66 1998
- PQ3919.2.M2866 C83 1994
- NA2500 .H64 1995
- DT423.E26 9th.ed. 2012
- PZ73.S758345255 2011
- PZ8.3.G276Lo 1971
Has 3 parts:
1. The class number... | 7,492 | Python | .py | 177 | 38.067797 | 88 | 0.668087 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:22Z",
"metrics": {
"/tmp/tmprl8gu4ax.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
260 | test_dateutil.py | internetarchive_openlibrary/openlibrary/utils/tests/test_dateutil.py | from .. import dateutil
import datetime
def test_parse_date():
assert dateutil.parse_date("2010") == datetime.date(2010, 1, 1)
assert dateutil.parse_date("2010-02") == datetime.date(2010, 2, 1)
assert dateutil.parse_date("2010-02-03") == datetime.date(2010, 2, 3)
def test_nextday():
assert dateutil.... | 1,622 | Python | .py | 32 | 45.40625 | 87 | 0.667724 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:24Z",
"metrics": {
"/tmp/tmpr0sqsyan.py": {
"CONFIDENCE.HIGH": 16,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 16,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
261 | test_lccn.py | internetarchive_openlibrary/openlibrary/utils/tests/test_lccn.py | import pytest
from openlibrary.utils.lccn import normalize_lccn
def test_normalize_lccn_prenormalized():
prenormalized = '94200274'
assert normalize_lccn(prenormalized) == prenormalized
lccns = [
('96-39190', '96039190'),
('agr 62000298', 'agr62000298'),
('agr 62-298', 'agr62000298'),
('agr6... | 821 | Python | .py | 25 | 29.12 | 57 | 0.661168 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:24Z",
"metrics": {
"/tmp/tmpimmuutxv.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
262 | test_utils.py | internetarchive_openlibrary/openlibrary/utils/tests/test_utils.py | from openlibrary.utils import (
extract_numeric_id_from_olid,
str_to_key,
)
def test_str_to_key():
assert str_to_key('x') == 'x'
assert str_to_key('X') == 'x'
assert str_to_key('[X]') == 'x'
assert str_to_key('!@<X>;:') == '!x'
assert str_to_key('!@(X);:') == '!(x)'
def test_extract_nume... | 465 | Python | .py | 13 | 31.692308 | 65 | 0.595982 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:24Z",
"metrics": {
"/tmp/tmp9_fjcw02.py": {
"CONFIDENCE.HIGH": 7,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 7,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
263 | test_retry.py | internetarchive_openlibrary/openlibrary/utils/tests/test_retry.py | from unittest.mock import Mock
import pytest
from openlibrary.utils.retry import MaxRetriesExceeded, RetryStrategy
class TestRetryStrategy:
def test_exception_filter(self, monkeytime):
foo = Mock(side_effect=ZeroDivisionError)
retry = RetryStrategy([ZeroDivisionError], max_retries=3)
with ... | 1,440 | Python | .py | 34 | 33.529412 | 70 | 0.66 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:25Z",
"metrics": {
"/tmp/tmp4cxtw3lk.py": {
"CONFIDENCE.HIGH": 7,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 7,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
264 | test_processors.py | internetarchive_openlibrary/openlibrary/utils/tests/test_processors.py | import web
import time
from ..processors import RateLimitProcessor
class TestRateLimitProcessor:
"""py.test testcase for testing RateLimitProcessor."""
def setup_method(self, method):
web.ctx.ip = "127.0.0.1"
def test_check_rate(self, monkeypatch):
monkeypatch.setattr(time, "time", lamb... | 974 | Python | .py | 25 | 31.28 | 65 | 0.624733 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:25Z",
"metrics": {
"/tmp/tmprs4w0i1j.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
265 | test_solr.py | internetarchive_openlibrary/openlibrary/utils/tests/test_solr.py | from ..solr import Solr
def test_prepare_select():
solr = Solr("http://localhost:8983/solr")
assert solr._prepare_select("foo") == "foo"
assert solr._prepare_select({"isbn": "1234567890"}) == 'isbn:"1234567890"'
assert (
solr._prepare_select({"isbn": ["1234567890", "9876543210"]})
== ... | 490 | Python | .py | 13 | 31.769231 | 78 | 0.598309 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:26Z",
"metrics": {
"/tmp/tmp69ce0g10.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
266 | test_lcc.py | internetarchive_openlibrary/openlibrary/utils/tests/test_lcc.py | import pytest
from openlibrary.utils.lcc import (
choose_sorting_lcc,
normalize_lcc_prefix,
normalize_lcc_range,
short_lcc_to_sortable_lcc,
sortable_lcc_to_short_lcc,
)
TESTS = [
('PZ-0073.00000000', 'pz73', 'PZ73', 'lower case'),
('PZ-0000.00000000', 'PZ', 'PZ', 'just class'),
('PZ-01... | 5,438 | Python | .py | 125 | 39.336 | 88 | 0.639735 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:26Z",
"metrics": {
"/tmp/tmp4gej5fm2.py": {
"CONFIDENCE.HIGH": 8,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 8,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
267 | test_isbn.py | internetarchive_openlibrary/openlibrary/utils/tests/test_isbn.py | import pytest
from openlibrary.utils.isbn import (
get_isbn_10_and_13,
isbn_10_to_isbn_13,
isbn_13_to_isbn_10,
normalize_identifier,
normalize_isbn,
opposite_isbn,
get_isbn_10s_and_13s,
)
def test_isbn_13_to_isbn_10():
assert isbn_13_to_isbn_10('978-0-940787-08-7') == '0940787083'
... | 3,320 | Python | .py | 89 | 32.393258 | 89 | 0.639539 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:27Z",
"metrics": {
"/tmp/tmppfqc4lbp.py": {
"CONFIDENCE.HIGH": 22,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 22,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
268 | test_ddc.py | internetarchive_openlibrary/openlibrary/utils/tests/test_ddc.py | import pytest
from openlibrary.utils.ddc import (
choose_sorting_ddc,
normalize_ddc,
normalize_ddc_prefix,
normalize_ddc_range,
)
# Src: https://www.oclc.org/bibformats/en/0xx/082.html
TESTS_FROM_OCLC = [
("370.19'342", ['370.19342'], "Segmentation (prime) marks"),
("370.19/342", ['370.19342']... | 5,634 | Python | .py | 141 | 34.758865 | 88 | 0.574877 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:27Z",
"metrics": {
"/tmp/tmp5i2ppsea.py": {
"CONFIDENCE.HIGH": 5,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 5,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
270 | model.py | internetarchive_openlibrary/openlibrary/accounts/model.py | """
"""
import secrets
import time
import datetime
import hashlib
import hmac
import random
import string
from typing import TYPE_CHECKING, Any
import uuid
import logging
import requests
from validate_email import validate_email
import web
from infogami import config
from infogami.utils.view import render_template,... | 32,512 | Python | .py | 794 | 31.309824 | 97 | 0.602953 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:28Z",
"metrics": {
"/tmp/tmpj9us7d19.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 2,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 2,
"SEVERITY.UND... |
271 | test_dump.py | internetarchive_openlibrary/openlibrary/tests/data/test_dump.py | import json
from openlibrary.data.dump import print_dump, pgdecode
class TestPrintDump:
def test_fixes_prefixes(self, capsys):
records = [
{
"key": "/b/OL1M",
"type": {"key": "/type/edition"},
"revision": 1,
"last_modified": {"va... | 1,737 | Python | .py | 50 | 22.48 | 78 | 0.4642 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:29Z",
"metrics": {
"/tmp/tmp_e0ymme_.py": {
"CONFIDENCE.HIGH": 5,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 5,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
272 | test_utils.py | internetarchive_openlibrary/openlibrary/tests/solr/test_utils.py | import json
from unittest.mock import MagicMock
import httpx
from httpx import Response, ConnectError
from openlibrary.solr.utils import SolrUpdateRequest, solr_update
class TestSolrUpdate:
def sample_response_200(self):
return Response(
200,
request=MagicMock(),
cont... | 4,647 | Python | .py | 123 | 23.439024 | 92 | 0.492109 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:29Z",
"metrics": {
"/tmp/tmp6qlyxaxs.py": {
"CONFIDENCE.HIGH": 6,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 6,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
273 | test_types_generator.py | internetarchive_openlibrary/openlibrary/tests/solr/test_types_generator.py | import os
from openlibrary.solr.types_generator import generate
root = os.path.dirname(__file__)
def test_up_to_date():
types_path = os.path.join(root, '..', '..', 'solr', 'solr_types.py')
assert (
generate().strip() == open(types_path).read().strip()
), """
This auto-generated file is out-... | 419 | Python | .py | 11 | 33.727273 | 76 | 0.650124 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:29Z",
"metrics": {
"/tmp/tmplpss7ftq.py": {
"CONFIDENCE.HIGH": 1,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 1,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
274 | test_update.py | internetarchive_openlibrary/openlibrary/tests/solr/test_update.py | import pytest
from openlibrary.core.ratings import WorkRatingsSummary
from openlibrary.solr import update
from openlibrary.solr.data_provider import DataProvider, WorkReadingLogSolrSummary
author_counter = 0
edition_counter = 0
work_counter = 0
def make_author(**kw):
"""
Create a fake author
:param kw:... | 3,860 | Python | .py | 116 | 25.362069 | 86 | 0.569123 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:30Z",
"metrics": {
"/tmp/tmpwn1ml4w_.py": {
"CONFIDENCE.HIGH": 4,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 4,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
275 | test_data_provider.py | internetarchive_openlibrary/openlibrary/tests/solr/test_data_provider.py | from unittest.mock import MagicMock
import pytest
from infogami.infobase.client import Thing
from openlibrary.solr.data_provider import BetterDataProvider
class TestBetterDataProvider:
@pytest.mark.asyncio
async def test_get_document(self):
mock_site = MagicMock()
dp = BetterDataProvider(
... | 1,634 | Python | .py | 50 | 21.82 | 61 | 0.522483 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:30Z",
"metrics": {
"/tmp/tmp1bwnqjht.py": {
"CONFIDENCE.HIGH": 6,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 6,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
276 | test_query_utils.py | internetarchive_openlibrary/openlibrary/tests/solr/test_query_utils.py | import pytest
from openlibrary.solr.query_utils import (
EmptyTreeError,
luqum_parser,
luqum_remove_child,
luqum_replace_child,
luqum_traverse,
luqum_replace_field,
luqum_remove_field,
)
REMOVE_TESTS = {
'Complete match': ('title:foo', 'title:foo', ''),
'Binary Op Left': ('title:foo... | 4,376 | Python | .py | 108 | 33.851852 | 88 | 0.605461 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:31Z",
"metrics": {
"/tmp/tmp2ntsd637.py": {
"CONFIDENCE.HIGH": 25,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 25,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
277 | test_author.py | internetarchive_openlibrary/openlibrary/tests/solr/updater/test_author.py | import httpx
import pytest
from openlibrary.solr.updater.author import AuthorSolrUpdater
from openlibrary.tests.solr.test_update import FakeDataProvider, make_author
class MockResponse:
def __init__(self, json_data, status_code=200):
self.json_data = json_data
self.status_code = status_code
d... | 1,756 | Python | .py | 42 | 27 | 76 | 0.490035 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:31Z",
"metrics": {
"/tmp/tmph9rvtp_y.py": {
"CONFIDENCE.HIGH": 3,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 3,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
278 | test_work.py | internetarchive_openlibrary/openlibrary/tests/solr/updater/test_work.py | import pytest
from openlibrary.solr.updater.work import (
WorkSolrBuilder,
WorkSolrUpdater,
)
from openlibrary.tests.solr.test_update import (
FakeDataProvider,
make_author,
make_edition,
make_work,
)
def sorted_split_semicolon(s):
"""
>>> sorted_split_semicolon("z;c;x;a;y;b")
['a'... | 19,960 | Python | .py | 521 | 27.570058 | 88 | 0.509443 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:32Z",
"metrics": {
"/tmp/tmpk2neke6m.py": {
"CONFIDENCE.HIGH": 103,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 103,
"SEVERITY.MEDIUM": 0,
"SEVERITY... |
279 | test_edition.py | internetarchive_openlibrary/openlibrary/tests/solr/updater/test_edition.py | import pytest
from openlibrary.solr.updater.edition import EditionSolrUpdater
from openlibrary.tests.solr.test_update import FakeDataProvider
class TestEditionSolrUpdater:
@pytest.mark.asyncio
async def test_deletes_old_orphans(self):
req, new_keys = await EditionSolrUpdater(FakeDataProvider()).updat... | 969 | Python | .py | 24 | 31.625 | 80 | 0.597444 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:32Z",
"metrics": {
"/tmp/tmp_u0w378j.py": {
"CONFIDENCE.HIGH": 6,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 6,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
280 | test_get_ia.py | internetarchive_openlibrary/openlibrary/tests/catalog/test_get_ia.py | import pytest
from pathlib import Path
from openlibrary.catalog import get_ia
from openlibrary.core import ia
from openlibrary.catalog.marc.marc_xml import MarcXml
from openlibrary.catalog.marc.marc_binary import MarcBinary, BadLength, BadMARC
TEST_DATA = Path(__file__).parents[2] / 'catalog' / 'marc' / 'tests' / 'te... | 4,747 | Python | .py | 108 | 36.037037 | 134 | 0.664719 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:33Z",
"metrics": {
"/tmp/tmpw0194pyx.py": {
"CONFIDENCE.HIGH": 2,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 2,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UND... |
281 | test_utils.py | internetarchive_openlibrary/openlibrary/tests/catalog/test_utils.py | import pytest
from datetime import datetime, timedelta
from openlibrary.catalog.utils import (
author_dates_match,
flip_name,
get_missing_fields,
get_non_isbn_asin,
get_publication_year,
is_asin_only,
is_independently_published,
is_promise_item,
match_with_bad_chars,
needs_isbn_... | 13,158 | Python | .py | 378 | 27.537037 | 88 | 0.554605 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:34Z",
"metrics": {
"/tmp/tmpqkw6cy8p.py": {
"CONFIDENCE.HIGH": 32,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 0,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 32,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
282 | test_models.py | internetarchive_openlibrary/openlibrary/tests/accounts/test_models.py | from openlibrary.accounts import model, InternetArchiveAccount, OpenLibraryAccount
from requests.models import Response
from unittest import mock
def get_username(account):
return account and account.value
def test_verify_hash():
secret_key = b"aqXwLJVOcV"
hash = model.generate_hash(secret_key, b"foo")
... | 3,011 | Python | .py | 80 | 31.2 | 82 | 0.665179 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:34Z",
"metrics": {
"/tmp/tmpl4zeelfi.py": {
"CONFIDENCE.HIGH": 10,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 3,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 13,
"SEVERITY.MEDIUM": 0,
"SEVERITY.U... |
283 | conftest.py | internetarchive_openlibrary/openlibrary/tests/core/conftest.py | import os
import pytest
@pytest.fixture
def dummy_crontabfile(request):
"Creates a dummy crontab file that can be used for to try things"
cronfile = os.tmpnam()
ip = """* * * * * /bin/true
* * * * * /bin/true"""
f = open(cronfile, "w")
f.write(ip)
f.close()
request.addfinalizer(lambda: os.... | 1,680 | Python | .py | 53 | 26.584906 | 70 | 0.656541 | internetarchive/openlibrary | 5,078 | 1,311 | 956 | AGPL-3.0 | 9/5/2024, 5:07:13 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false | false | false | {
"errors": [],
"generated_at": "2025-07-09T10:22:34Z",
"metrics": {
"/tmp/tmplqc1_nfr.py": {
"CONFIDENCE.HIGH": 0,
"CONFIDENCE.LOW": 0,
"CONFIDENCE.MEDIUM": 2,
"CONFIDENCE.UNDEFINED": 0,
"SEVERITY.HIGH": 0,
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 2,
"SEVERITY.UND... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.