astro_metadata_translator.indexing.index_files(files: ~typing.Sequence[str], root: ~typing.Optional[str], hdrnum: int, print_trace: bool, content: str, outstream: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, errstream: ~typing.IO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>) Tuple[MutableMapping[str, Union[str, MutableMapping[str, Any]]], List[str], List[str]]

Create an index from the supplied files.

No file is written. The Python structure returned is suitable for writing.

filesiterable of str

Paths to the files to be indexed. They do not have to all be in a single directory but all content will be indexed into a single index.


Directory root that can be combined with each file (if the supplied) file is relative. Will be ignored if None.


The HDU number to read. The primary header is always read and


If there is an error reading the file and this parameter is True, a full traceback of the exception will be reported. If False prints a one line summary of the error condition. If None the exception will be allowed.


Form of data to write in index file. Options are: translated (default) to write ObservationInfo to the index; metadata to write native metadata headers to the index. The index file is called {mode}_index.json

outstreamio.StringIO, optional

Output stream to use for standard messages. Defaults to sys.stdout.

errstreamio.StringIO, optional

Stream to send messages that would normally be sent to standard error. Defaults to sys.stderr.

file_indexdict of [str, dict]

The headers in form suitable for writing to an index. The keys will be __COMMON__ for shared content, __CONTENT_ to record the content mode used to construct the index, and paths to the files. The paths will be the supplied paths and will not include any supplied root.

okaylist of str

All the files that were processed successfully.

failedlist of str

All the files that could not be processed. Will be empty if print_trace is not None.