Skip to content

Instantly share code, notes, and snippets.

View danizen's full-sized avatar

Dan Davis danizen

View GitHub Profile
@danizen
danizen / marcindex.py
Created July 5, 2022 21:40
Index a MARC file so you can read only the parts you need
import io
import logging
import os
import mmap
import time
from collections.abc import Sequence
from struct import pack, unpack
LOG = logging.getLogger(__name__)
from __future__ import annotations
from collections.abc import Collection
from pathlib import Path
from typing import Optional, Type, Any, Literal, Union, Annotated
from typing_extensions import Self
from pydantic import ValidationError
from pydantic.fields import AliasChoices, Field
from pydantic_settings import (
BaseSettings,
PydanticBaseSettingsSource,