colrev.package_manager.package_base_classes.SearchSourcePackageBaseClass

class colrev.package_manager.package_base_classes.SearchSourcePackageBaseClass(*, search_file, logger=None, verbose_mode=False)[source]

Bases: ABC

The base class for SearchSource packages.

The following cli commands call specific methods of a SearchSource package:

colrev search --add package_name -> calls package.add_endpoint()

colrev search -> calls search operation -> calls package.search()

colrev load -> calls load operation -> calls package.load()

colrev prep -> calls prep operation -> calls package.prep()

Initialize the instance.

Methods

add_endpoint

Add the SearchSource as an endpoint.

ensure_append_only

Ensure that the SearchSource is append-only (override this method if needed).

heuristic

Heuristic to identify which SearchSource a search file belongs to.

load

Load normalized SearchSource records through bibliography-io.

normalize

Normalize parsed records and return them indexed by unique ID.

prep_link_md

Retrieve masterdata from the SearchSource.

prepare

Run the custom source-prep operation.

preprocess

Preprocess source text before parsing it.

preprocess_file

Preprocess a source file before parsing it.

search

Run a search of the SearchSource.

Attributes

CURRENT_SYNTAX_VERSION

ci_supported

endpoint

source_identifier

search_types

heuristic_status

search_source

abstract classmethod add_endpoint(params, path, logger=None)[source]

Add the SearchSource as an endpoint.

Return type:

ExtendedSearchFile

classmethod ensure_append_only(filename)[source]

Ensure that the SearchSource is append-only (override this method if needed).

Return type:

bool

abstract classmethod heuristic(filename, data)[source]

Heuristic to identify which SearchSource a search file belongs to.

Return type:

dict

load()[source]

Load normalized SearchSource records through bibliography-io.

Return type:

dict

classmethod normalize(records, *, format, source_version)[source]

Normalize parsed records and return them indexed by unique ID.

Existing unique IDs are preserved. Missing or repeated IDs receive the next available zero-padded numeric ID.

Return type:

dict[str, dict]

Retrieve masterdata from the SearchSource.

Return type:

Record

abstract prepare(record)[source]

Run the custom source-prep operation.

Return type:

Record

classmethod preprocess(text, *, format, source_version)[source]

Preprocess source text before parsing it.

Search sources can override this hook to handle source-specific exports. The default keeps the source text unchanged.

Return type:

str

classmethod preprocess_file(path, *, format, source_version, output_dir)[source]

Preprocess a source file before parsing it.

Search sources can override this hook for file-based transformations. Implementations must leave the original file unchanged and write any transformed files under output_dir. The default returns path unchanged.

Return type:

Path

abstract search(rerun)[source]

Run a search of the SearchSource.

Return type:

None