@contextlib.contextmanager
def _open_archive(archive, directory):
    'Manages a directory in which an existing SDK is laid out.'
    if directory:
        (yield directory)
    elif archive:
        temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger')
        with tarfile.open(archive) as archive_file:
            archive_file.extractall(temp_dir)
        try:
            (yield temp_dir)
        finally:
            shutil.rmtree(temp_dir, ignore_errors=True)
    else:
        raise Exception('Error: archive or directory must be set')
Manages a directory in which an existing SDK is laid out.
@contextlib.contextmanager
def _open_archive(archive, directory):
    
    if directory:
        (yield directory)
    elif archive:
        temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger')
        with tarfile.open(archive) as archive_file:
            archive_file.extractall(temp_dir)
        try:
            (yield temp_dir)
        finally:
            shutil.rmtree(temp_dir, ignore_errors=True)
    else:
        raise Exception('Error: archive or directory must be set')