def cache_available(config):
 if config.has_option('cache', 'cache_dir'):
  dpath = config.get('cache', 'cache_dir')
  try:
   existing = os.stat('/'.join([dpath, 'inventory']))
  except:
   return False
  if config.has_option('cache', 'cache_max_age'):
   maxage = config.get('cache', 'cache_max_age')
   if ((int(time.time()) - int(existing.st_mtime)) <= int(maxage)):
    return True
 return False

def cache_available ( config ) : if config . has_option ( 'cache' , 'cache_dir' ) : dpath = config . get ( 'cache' , 'cache_dir' ) try : existing = os . stat ( '/' . join ( [ dpath , 'inventory' ] ) ) except : return False if config . has_option ( 'cache' , 'cache_max_age' ) : maxage = config . get ( 'cache' , 'cache_max_age' ) if ( ( int ( time . time ( ) ) - int ( existing . st_mtime ) ) <= int ( maxage ) ) : return True return False
checks if we have a fresh cache available for item requested .