directory.cli

Imports directories scraped by ogi-scraper into onegov directories.

Attributes

cli

Functions

import_directory_from_ogi_scraper(...)

Imports a directory from a self-describing ogi-scraper JSON export.

Module Contents

directory.cli.cli[source]
directory.cli.import_directory_from_ogi_scraper(file: str, dry_run: bool) collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

Imports a directory from a self-describing ogi-scraper JSON export.

The file carries both the directory spec and its entries:

{
  "directory": {
    "title": "Vereine",
    "structure": "Name *= ___\\n...",       # onegov formcode
    "configuration": { ... },                # DirectoryConfiguration
    "fields": { "<field_id>": "<record_key>", ... }
  },
  "entries": [ { ...record... }, ... ]
}

The scraper is the source that knows the target shape, so this command needs no per-directory knowledge. The directory is created if missing and entries are matched by name and updated in place, so the import is idempotent.

Example:

onegov-directory –select /onegov_town6/malters \

import-from-ogi-scraper vereinsliste.json