def get_cache_base(suffix=None):
 if (suffix is None):
  suffix = '.distlib'
 if ((os.name == 'nt') and ('LOCALAPPDATA' in os.environ)):
  result = os.path.expandvars('$localappdata')
 else:
  result = os.path.expanduser('~')
 if os.path.isdir(result):
  usable = os.access(result, os.W_OK)
  if (not usable):
   logger.warning('Directory exists but is not writable: %s', result)
 else:
  try:
   os.makedirs(result)
   usable = True
  except OSError:
   logger.warning('Unable to create %s', result, exc_info=True)
   usable = False
 if (not usable):
  result = tempfile.mkdtemp()
  logger.warning('Default location unusable, using %s', result)
 return os.path.join(result, suffix)

def get_cache_base ( suffix = None ) : if ( suffix is None ) : suffix = '.distlib' if ( ( os . name == 'nt' ) and ( 'LOCALAPPDATA' in os . environ ) ) : result = os . path . expandvars ( '$localappdata' ) else : result = os . path . expanduser ( '~' ) if os . path . isdir ( result ) : usable = os . access ( result , os . W_OK ) if ( not usable ) : logger . warning ( 'Directory exists but is not writable: %s' , result ) else : try : os . makedirs ( result ) usable = True except OSError : logger . warning ( 'Unable to create %s' , result , exc_info = True ) usable = False if ( not usable ) : result = tempfile . mkdtemp ( ) logger . warning ( 'Default location unusable, using %s' , result ) return os . path . join ( result , suffix )
return the default base location for distlib caches .