@staticmethod
    def _extract_from_file(file_pattern, file_description, extract_function):

        try:
            md_path = glob.glob(file_pattern)[0]

            md_file = open(md_path)
            metadata = extract_function(md_file)
            md_file.close()

        except IndexError:  # File not found
            metadata = None
            LOGGER.debug('No %s file found.', file_description)

        except IOError:  # Open failed
            raise DatasetError('Unable to open %s file.' % file_description)

        return metadata
Extract metadata from a file.
dataset/ETHPy150Open GeoscienceAustralia/agdc/src/landsat_ingester/landsat_dataset.py/LandsatDataset._extract_from_file