def unpackFromCache(cache_key, to_directory):
if cache_key is None:<EOL><INDENT>raise NotInCache('<STR_LIT>')<EOL><DEDENT>cache_key = _encodeCacheKey(cache_key)<EOL>cache_dir = folders.cacheDirectory()<EOL>fsutils.mkDirP(cache_dir)<EOL>path = os.path.join(cache_dir, cache_key)<EOL>logger.debug('<STR_LIT>', path, to_directory)<EOL>try:<EOL><INDENT>unpackFrom(path, to_directory)<EOL>try:<EOL><INDENT>shutil.copy(path + '<STR_LIT>', os.path.join(to_directory, '<STR_LIT>'))<EOL><DEDENT>except IOError as e:<EOL><INDENT>if e.errno == errno.ENOENT:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>cache_logger.debug('<STR_LIT>', cache_key, to_directory)<EOL>return<EOL><DEDENT>except IOError as e:<EOL><INDENT>if e.errno == errno.ENOENT:<EOL><INDENT>cache_logger.debug('<STR_LIT>', cache_key)<EOL>raise NotInCache('<STR_LIT>')<EOL><DEDENT><DEDENT>except OSError as e:<EOL><INDENT>if e.errno == errno.ENOTEMPTY:<EOL><INDENT>logger.error('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>
If the specified cache key exists, unpack the tarball into the
        specified directory, otherwise raise NotInCache (a KeyError subclass).