read_file_info#

astro_metadata_translator.file_helpers.read_file_info(file, hdrnum, print_trace=None, content_mode='translated', content_type='simple', outstream=None)#

Read information from file.

Parameters:
  • file (str) – The file from which the header is to be read.

  • hdrnum (int) – The HDU number to read. The primary header is always read and merged with the header from this HDU.

  • print_trace (bool 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_mode (str) – Content returned. This can be: metadata to return the unfixed metadata headers; translated to return the output from metadata translation.

  • content_type (str, 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.

  • outstream (io.StringIO or None, optional) – Output stream to use for standard messages. Defaults to None which uses the default output stream.

Returns:

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

Return type:

dict of str or ObservationInfo