def __enter__(self) -> str:
    if ('KACHERY_STORAGE_DIR' in os.environ):
        storage_dir = os.getenv('KACHERY_STORAGE_DIR')
    else:
        storage_dir = None
    if (storage_dir is not None):
        dirpath = os.path.join(storage_dir, 'tmp')
        if (not os.path.exists(dirpath)):
            try:
                os.mkdir(dirpath)
            except:
                if (not os.path.exists):
                    raise Exception(f'Unexpected problem creating temporary directory: {dirpath}')
    else:
        dirpath = None
    self._path = str(tempfile.mkdtemp(prefix=self._prefix, dir=dirpath))
    return self._path
def __enter__(self) -> str:
    if ('KACHERY_STORAGE_DIR' in os.environ):
        storage_dir = os.getenv('KACHERY_STORAGE_DIR')
    else:
        storage_dir = None
    if (storage_dir is not None):
        dirpath = os.path.join(storage_dir, 'tmp')
        if (not os.path.exists(dirpath)):
            try:
                os.mkdir(dirpath)
            except:
                if (not os.path.exists):
                    raise Exception(f'Unexpected problem creating temporary directory: {dirpath}')
    else:
        dirpath = None
    self._path = str(tempfile.mkdtemp(prefix=self._prefix, dir=dirpath))
    return self._path