read_file_info

astro_metadata_translator.file_helpers.read_file_info(file: str, hdrnum: int, print_trace: bool | None = None, content_mode: str = 'translated', content_type: str = 'simple', outstream: IO | None = None) str | MutableMapping[str, Any] | ObservationInfo | None

Read information from file.

Parameters:
filestr

The file from which the header is to be read.

hdrnumint

The HDU number to read. The primary header is always read and merged with the header from this HDU.

print_tracebool or None

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 to propagate.

content_modestr

Content returned. This can be: metadata to return the unfixed metadata headers; translated to return the output from metadata translation.

content_typestr, optional

Form of content to be returned. Can be either json to return a JSON string, simple to always return a dict, or native to return either a dict (for metadata) or ObservationInfo for translated.

outstreamio.StringIO or None, optional

Output stream to use for standard messages. Defaults to None which uses the default output stream.

Returns:
simpledict of str or ObservationInfo

The return value of ObservationInfo.to_simple. Returns None if there was a problem and print_trace is not None.