@contextlib.contextmanager<EOL><INDENT>def get_inventory_temp_file(self, keys=None):<DEDENT>
temp_file = tempfile.NamedTemporaryFile(mode='<STR_LIT>')<EOL>inventory = self.get_inventory_str(keys)<EOL>LOGGER.debug(<EOL>'<STR_LIT>'.format(<EOL>temp_file.name, inventory<EOL>)<EOL>)<EOL>temp_file.write(inventory)<EOL>temp_file.flush()<EOL>temp_file.seek(<NUM_LIT:0>)<EOL>yield temp_file<EOL>temp_file.close()<EOL>
Context manager which returns the inventory written on a tempfile.
The tempfile will be deleted as soon as this context manger ends.

Args:
    keys (list of str): Path to the keys that will be used to
        create groups.

Yields:
    tempfile.NamedTemporaryFile: Temp file containing the inventory