parameters: (cache_path)
return_statement: return (total, contents)
docstring: Collect the cache contents.
docstring_summary: Collect the cache contents.
docstring_tokens: Collect the cache contents .
function: def collect_cache_contents(cache_path):
      """Collect the cache contents."""
      # map folder names to timestamps
      contents = []
      total = 0
  
      # collect names of directories and creation times
      for name in os.listdir(cache_path):
          path = os.path.join(cache_path, name)
  
          if os.path.isdir(path):
              for file_name in os.listdir(path):
                  file_path = os.path.join(path, file_name)
                  # Cache prune script is allowing only directories with this extension
                  # which comes from the validate_cache_dir.py tool in SCons, it must match
                  # the extension set in that file.
                  cksum_type = False
                  if os.path.isdir(file_path):
                      hash_length = -32
                      tmp_length = -len('.cksum.tmp') + hash_length
                      cksum_type = (file_path.lower().endswith('.cksum')
                                    or file_path.lower().endswith('.del')
                                    or file_path.lower()[tmp_length:hash_length] == '.cksum.tmp')
  
                      if not cksum_type:
                          LOGGER.warning(
                              "cache item %s is a directory and not a file. "
                              "The cache may be corrupt.", file_path)
                          continue
  
                  try:
  
                      item = CacheItem(path=file_path, time=os.stat(file_path).st_atime,
                                       size=get_cachefile_size(file_path, cksum_type))
  
                      total += item.size
  
                      contents.append(item)
                  except OSError as err:
                      LOGGER.warning("Ignoring error querying file %s : %s", file_path, err)
  
      return (total, contents)
function_tokens: def collect_cache_contents ( cache_path ) : # map folder names to timestamps contents = [ ] total = 0 # collect names of directories and creation times for name in os . listdir ( cache_path ) : path = os . path . join ( cache_path , name ) if os . path . isdir ( path ) : for file_name in os . listdir ( path ) : file_path = os . path . join ( path , file_name ) # Cache prune script is allowing only directories with this extension # which comes from the validate_cache_dir.py tool in SCons, it must match # the extension set in that file. cksum_type = False if os . path . isdir ( file_path ) : hash_length = - 32 tmp_length = - len ( '.cksum.tmp' ) + hash_length cksum_type = ( file_path . lower ( ) . endswith ( '.cksum' ) or file_path . lower ( ) . endswith ( '.del' ) or file_path . lower ( ) [ tmp_length : hash_length ] == '.cksum.tmp' ) if not cksum_type : LOGGER . warning ( "cache item %s is a directory and not a file. " "The cache may be corrupt." , file_path ) continue try : item = CacheItem ( path = file_path , time = os . stat ( file_path ) . st_atime , size = get_cachefile_size ( file_path , cksum_type ) ) total += item . size contents . append ( item ) except OSError as err : LOGGER . warning ( "Ignoring error querying file %s : %s" , file_path , err ) return ( total , contents )