Fetchez Hooks#

Hooks allow you to intercept, filter, and modify data before, during or after the fetch process.

fetchez.hooks.__init__#

This init file also holds the FetchHook super class

copyright:
  1. 2010-2026 Regents of the University of Colorado

license:

MIT, see LICENSE for more details.

class fetchez.hooks.FetchHook(stage=None, **kwargs)[source]#

Bases: object

Base class for all Fetchez Hooks.

name = 'base_hook'#
desc = 'Does something.'#
category = 'uncategorized'#
__init__(stage=None, **kwargs)[source]#
stage = 'file'#
teardown()[source]#

Cleanup.

Called strictly once after all processing is complete. Override this to close files, finalize grids, or print summaries.

run(entry)[source]#

Execute the hook.

Parameters:

entry – For ‘file’ stage: [url, path, type, status] For ‘pre’/’post’: The full list of results (so far) or context.

Returns:

Modified entry (for ‘file’ stage pipeline) or None.

fetchez.hooks.registry#

This holds the hook registry.

copyright:
  1. 2010-2026 Regents of the University of Colorado

license:

MIT, see LICENSE for more details.

class fetchez.hooks.registry.HookRegistry[source]#

Bases: object

classmethod load_builtins()[source]#

Recursively scan and load all built-in hooks from the ‘builtins’ directory.

classmethod load_user_plugins()[source]#

Scan ~/.fetchez/hooks/ and .fetchez/hooks for python files.

classmethod register_hook(hook_cls)[source]#

Register a hook class.

The hook must have a ‘name’ attribute (e.g. name=’unzip’).

classmethod get_hook(name)[source]#

Retrieve a hook class by name.

classmethod list_hooks()[source]#

Return a dict of all registered hooks.