def cachefile(src, dst, api=None, logger=None):
 lcache = os.path.join(os.path.dirname(os.path.dirname(dst)), '.link_cache')
 if (not os.path.isdir(lcache)):
  os.mkdir(lcache)
 key = hashfile(src, lcache=lcache, logger=logger)
 cachefile = os.path.join(lcache, key)
 if (not os.path.exists(cachefile)):
  logger.info(('trying to create cache file %s' % cachefile))
  copyfile(src, cachefile, api=api, logger=logger)
 logger.debug(('trying cachelink %s -> %s -> %s' % (src, cachefile, dst)))
 os.link(cachefile, dst)

def cachefile ( src , dst , api = None , logger = None ) : lcache = os . path . join ( os . path . dirname ( os . path . dirname ( dst ) ) , '.link_cache' ) if ( not os . path . isdir ( lcache ) ) : os . mkdir ( lcache ) key = hashfile ( src , lcache = lcache , logger = logger ) cachefile = os . path . join ( lcache , key ) if ( not os . path . exists ( cachefile ) ) : logger . info ( ( 'trying to create cache file %s' % cachefile ) ) copyfile ( src , cachefile , api = api , logger = logger ) logger . debug ( ( 'trying cachelink %s -> %s -> %s' % ( src , cachefile , dst ) ) ) os . link ( cachefile , dst )
copy a file into a cache and link it into place .