index_files#
- astro_metadata_translator.indexing.index_files(files, root, hdrnum, print_trace, content, outstream=None)#
Create an index from the supplied files.
No file is written. The Python structure returned is suitable for writing.
- Parameters:
files (iterable of
lsst.resources.ResourcePathExpression) – 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.root (
str) – Directory root that can be combined with each file (if the supplied) file is relative. Will be ignored ifNone.hdrnum (
int) – The HDU number to read. The primary header is always read and merged with the header from this HDU.print_trace (
bool) – If there is an error reading the file and this parameter isTrue, a full traceback of the exception will be reported. IfFalseprints a one line summary of the error condition. IfNonethe exception will be allowed.content (
str) – Form of data to write in index file. Options are:translated(default) to write ObservationInfo to the index;metadatato write native metadata headers to the index. The index file is called{mode}_index.json.outstream (
io.StringIO, optional) – Output stream to use for standard messages. Defaults toNonewhich uses the default output stream.
- Return type:
tuple[MutableMapping[str,str|MutableMapping[str,Any]],list[str],list[str]]- Returns:
file_index (
dictof [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 suppliedroot.okay (
listofstr) – All the files that were processed successfully.failed (
listofstr) – All the files that could not be processed. Will be empty ifprint_traceis notNone.