Skip to content

API Reference parrot_tools.scraping.base_registry

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.scraping.base_registry

View source

BasePlanRegistry — Generic disk-backed plan registry.

Provides the shared 3-tier URL lookup and CRUD operations for all plan registry types. Subclass with a concrete plan model (e.g. ScrapingPlan or ExtractionPlan) to get a fully functional registry without duplicating boilerplate.

Class BasePlanRegistry

Generic disk-backed plan registry with 3-tier URL lookup.

Provides load/save, lookup (exact → path-prefix → domain), register, touch, remove, and invalidate operations against a JSON index file on disk. All write operations are guarded by an asyncio.Lock.

Subclasses should override register if they need plan-type-specific index entry construction.

Parameter Type Default Description
plans_dir Optional[Path] None Directory for plan files and the index file. Defaults to scraping_plans in the current working directory.
index_filename str 'registry.json' Name of the JSON index file inside plans_dir. Defaults to registry.json.

Method BasePlanRegistry.load

Load registry index from disk.

Reads the index JSON file and populates the in-memory entries dict. If the file does not exist, starts with an empty registry.

load() -> None

Method BasePlanRegistry.lookup

Three-tier lookup: exact fingerprint -> path-prefix -> domain.

lookup(url: str, *, allow_domain_fallback: bool = True) -> Optional[PlanRegistryEntry]

Parameter Type Default Description
url str Target URL to look up.
allow_domain_fallback bool True When True (default), Tier 3 returns any plan from the same domain if Tier 1 and Tier 2 miss. Set to False when the caller has a specific extraction intent for this URL (e.g. an objective was supplied) — returning a plan made for an unrelated path on the same domain would silently scrape the wrong page.

Returns: Optional[PlanRegistryEntry] — Matching PlanRegistryEntry or None if no match.

Method BasePlanRegistry.get_by_name

Look up an entry by plan name.

get_by_name(name: str) -> Optional[PlanRegistryEntry]

Parameter Type Default Description
name str Plan name to search for.

Returns: Optional[PlanRegistryEntry] — Matching entry or None.

Method BasePlanRegistry.list_all

Return all registry entries.

list_all() -> List[PlanRegistryEntry]

Returns: List[PlanRegistryEntry] — List of all PlanRegistryEntry objects in the registry.

Method BasePlanRegistry.register

Register a plan in the index and persist to disk.

Builds a PlanRegistryEntry from the plan's name, url, domain, fingerprint, and optional version / tags attributes, then saves the updated index.

register(plan: T, relative_path: str) -> None

Parameter Type Default Description
plan T The plan object to register. Must satisfy PlanLike (i.e. have name, url, domain, fingerprint, version attributes).
relative_path str Path to the plan file relative to plans_dir.

Method BasePlanRegistry.touch

Update last_used_at and increment use_count for an entry.

touch(fingerprint: str) -> None

Parameter Type Default Description
fingerprint str The fingerprint of the entry to touch.

Method BasePlanRegistry.remove

Remove an entry by name.

remove(name: str) -> bool

Parameter Type Default Description
name str The plan name to remove.

Returns: bool — True if the entry was found and removed, False otherwise.

Method BasePlanRegistry.invalidate

Invalidate and remove an entry by fingerprint.

invalidate(fingerprint: str) -> None

Parameter Type Default Description
fingerprint str The fingerprint of the entry to remove.

Class PlanLike

Protocol that all registrable plan types must satisfy.

Every concrete plan model passed to BasePlanRegistry.register() must expose these attributes. Using a Protocol removes the need for type: ignore comments and lets mypy / pyright verify callers at import time.

Attributes:

Attribute Type Description
name Optional[str]
url str
domain str
fingerprint str
version int

Alias PlanRegistryEntry

Re-exported from parrot_tools.scraping.plan.PlanRegistryEntry.

Attribute T

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally