## scan()


Index the kernel files under *directory*, or under every configured root.


Usage

``` python
scan(
    directory=None,
    *,
    mission=None,
)
```


Opens the database named in the config, does one thing and closes it. This function calls [KernelDB.scan_directory](KernelDB.scan_directory.md#spice_kernel_db.KernelDB.scan_directory), or [KernelDB.scan_roots](KernelDB.scan_roots.md#spice_kernel_db.KernelDB.scan_roots) when *directory* is `None`.


## Parameters


`directory: str | Path | None = None`  
The directory to index. `None` indexes every configured kernel root.

`mission: str | None = None`  
File everything under this mission instead of detecting it from the path. It applies only together with *directory*. Scanning the configured roots always detects the mission.


## Returns


`int`  
The number of files registered.
