parameters: (version=DEFAULT_VERSION, download_base=DEFAULT_URL,
                          to_dir=os.curdir, delay=15)
return_statement: return os.path.realpath(saveto)
docstring: Download distribute from a specified location and return its filename
  
      `version` should be a valid distribute version number that is available
      as an egg for download under the `download_base` URL (which should end
      with a '/'). `to_dir` is the directory where the egg will be downloaded.
      `delay` is the number of seconds to pause before an actual download
      attempt.
docstring_summary: Download distribute from a specified location and return its filename
docstring_tokens: Download distribute from a specified location and return its filename
function: def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
                          to_dir=os.curdir, delay=15):
      """Download distribute from a specified location and return its filename
  
      `version` should be a valid distribute version number that is available
      as an egg for download under the `download_base` URL (which should end
      with a '/'). `to_dir` is the directory where the egg will be downloaded.
      `delay` is the number of seconds to pause before an actual download
      attempt.
      """
      # making sure we use the absolute path
      to_dir = os.path.abspath(to_dir)
      try:
          from urllib.request import urlopen
      except ImportError:
          from urllib2 import urlopen
      tgz_name = "distribute-%s.tar.gz" % version
      url = download_base + tgz_name
      saveto = os.path.join(to_dir, tgz_name)
      src = dst = None
      if not os.path.exists(saveto):  # Avoid repeated downloads
          try:
              log.warn("Downloading %s", url)
              src = urlopen(url)
              # Read/write all in one block, so we don't create a corrupt file
              # if the download is interrupted.
              data = src.read()
              dst = open(saveto, "wb")
              dst.write(data)
          finally:
              if src:
                  src.close()
              if dst:
                  dst.close()
      return os.path.realpath(saveto)
function_tokens: def download_setuptools ( version = DEFAULT_VERSION , download_base = DEFAULT_URL , to_dir = os . curdir , delay = 15 ) : # making sure we use the absolute path to_dir = os . path . abspath ( to_dir ) try : from urllib . request import urlopen except ImportError : from urllib2 import urlopen tgz_name = "distribute-%s.tar.gz" % version url = download_base + tgz_name saveto = os . path . join ( to_dir , tgz_name ) src = dst = None if not os . path . exists ( saveto ) : # Avoid repeated downloads try : log . warn ( "Downloading %s" , url ) src = urlopen ( url ) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = src . read ( ) dst = open ( saveto , "wb" ) dst . write ( data ) finally : if src : src . close ( ) if dst : dst . close ( ) return os . path . realpath ( saveto )