@contextlib.contextmanager
def _open_output(archive, directory):
    'Manages the output of this script.'
    if directory:
        shutil.rmtree(directory, ignore_errors=True)
        (yield directory)
    elif archive:
        temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger')
        try:
            (yield temp_dir)
            with tarfile.open(archive, 'w:gz') as archive_file:
                archive_file.add(temp_dir, arcname='')
        finally:
            shutil.rmtree(temp_dir, ignore_errors=True)
    else:
        raise Exception('Error: archive or directory must be set')
Manages the output of this script.
@contextlib.contextmanager
def _open_output(archive, directory):
    
    if directory:
        shutil.rmtree(directory, ignore_errors=True)
        (yield directory)
    elif archive:
        temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger')
        try:
            (yield temp_dir)
            with tarfile.open(archive, 'w:gz') as archive_file:
                archive_file.add(temp_dir, arcname=)
        finally:
            shutil.rmtree(temp_dir, ignore_errors=True)
    else:
        raise Exception('Error: archive or directory must be set')