<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _results_dir_path(self, key, stable):
 """Return a results directory path for the given key. :param key: A CacheKey to generate an id for. :param stable: True to use a stable subdirectory, false to use a portion of the cache key to generate a path unique to the key. """

    # TODO: Shorten cache_key hashes in general?
    return os.path.join(
      self._results_dir_prefix,
      key.id,
      self._STABLE_DIR_NAME if stable else sha1(key.hash.encode('utf-8')).hexdigest()[:12]
    )