def prereq_cache(cache_name, paths, install_func):
 cache_filename = cache_name.replace(' ', '_')
 cache_file_path = os.path.join(PREREQS_STATE_DIR, '{}.sha1'.format(cache_filename))
 old_hash = None
 if os.path.isfile(cache_file_path):
  with open(cache_file_path) as cache_file:
   old_hash = cache_file.read()
 new_hash = compute_fingerprint(paths)
 if (new_hash != old_hash):
  install_func()
  create_prereqs_cache_dir()
  with open(cache_file_path, 'w') as cache_file:
   post_install_hash = compute_fingerprint(paths)
   cache_file.write(post_install_hash)
 else:
  print '{cache} unchanged, skipping...'.format(cache=cache_name)

def prereq_cache ( cache_name , paths , install_func ) : cache_filename = cache_name . replace ( ' ' , '_' ) cache_file_path = os . path . join ( PREREQS_STATE_DIR , '{}.sha1' . format ( cache_filename ) ) old_hash = None if os . path . isfile ( cache_file_path ) : with open ( cache_file_path ) as cache_file : old_hash = cache_file . read ( ) new_hash = compute_fingerprint ( paths ) if ( new_hash != old_hash ) : install_func ( ) create_prereqs_cache_dir ( ) with open ( cache_file_path , 'w' ) as cache_file : post_install_hash = compute_fingerprint ( paths ) cache_file . write ( post_install_hash ) else : print '{cache} unchanged, skipping...' . format ( cache = cache_name )
conditionally execute install_func() only if the files/directories specified by paths have changed .