Skip to content

Createocrsource

snoop.data.management.commands.createocrsource #

Command to create snoop.data.models.OcrSource.

Classes#

Command #

Creates an OCR source.

Searches file at a pre-defined path, see snoop.data.models.OcrSource for details.

Methods#
add_arguments(self, parser) #

Entry point for subclassed commands to add custom arguments.

Source code in snoop/data/management/commands/createocrsource.py
def add_arguments(self, parser):
    parser.add_argument('collection', help="collection name")
    parser.add_argument('name', type=Path, help="OCR source name. "
                        "Files will be searched under $collections/$collection/ocr/$name.")
handle(self, collection, name, *args, **options) #

The actual logic of the command. Subclasses must implement this method.

Source code in snoop/data/management/commands/createocrsource.py
def handle(self, collection, name, *args, **options):
    assert collection in collections.ALL, 'collection does not exist'
    with collections.ALL[collection].set_current():
        ocr.create_ocr_source(name=name)