@staticmethod
    def _extract_from_file(file_pattern, file_description, extract_function):
        """Extract metadata from a file.

        Returns the result of running extract_function on the opened
        file, or None if the file cannot be found. file_pattern is a
        glob pattern for the file: the first file found is used.
        file_description is a description of the file for logging and
        error messages."""

        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 __HOLE__:  # Open failed
            raise DatasetError('Unable to open %s file.' % file_description)

        return metadata
dataset/ETHPy150Open GeoscienceAustralia/agdc/src/landsat_ingester/landsat_dataset.py/LandsatDataset._extract_from_file