parameters: (self, spec, tmpdir)
return_statement: return getattr(self.fetch_distribution(spec, tmpdir), 'location', None)
docstring: Locate and/or download `spec` to `tmpdir`, returning a local path
  
          `spec` may be a ``Requirement`` object, or a string containing a URL,
          an existing local filename, or a project/version requirement spec
          (i.e. the string form of a ``Requirement`` object).  If it is the URL
          of a .py file with an unambiguous ``#egg=name-version`` tag (i.e., one
          that escapes ``-`` as ``_`` throughout), a trivial ``setup.py`` is
          automatically created alongside the downloaded file.
  
          If `spec` is a ``Requirement`` object or a string containing a
          project/version requirement spec, this method returns the location of
          a matching distribution (possibly after downloading it to `tmpdir`).
          If `spec` is a locally existing file or directory name, it is simply
          returned unchanged.  If `spec` is a URL, it is downloaded to a subpath
          of `tmpdir`, and the local filename is returned.  Various errors may be
          raised if a problem occurs during downloading.
docstring_summary: Locate and/or download `spec` to `tmpdir`, returning a local path
docstring_tokens: Locate and / or download spec to tmpdir returning a local path
function: def download(self, spec, tmpdir):
          """Locate and/or download `spec` to `tmpdir`, returning a local path
  
          `spec` may be a ``Requirement`` object, or a string containing a URL,
          an existing local filename, or a project/version requirement spec
          (i.e. the string form of a ``Requirement`` object).  If it is the URL
          of a .py file with an unambiguous ``#egg=name-version`` tag (i.e., one
          that escapes ``-`` as ``_`` throughout), a trivial ``setup.py`` is
          automatically created alongside the downloaded file.
  
          If `spec` is a ``Requirement`` object or a string containing a
          project/version requirement spec, this method returns the location of
          a matching distribution (possibly after downloading it to `tmpdir`).
          If `spec` is a locally existing file or directory name, it is simply
          returned unchanged.  If `spec` is a URL, it is downloaded to a subpath
          of `tmpdir`, and the local filename is returned.  Various errors may be
          raised if a problem occurs during downloading.
          """
          if not isinstance(spec, Requirement):
              scheme = URL_SCHEME(spec)
              if scheme:
                  # It's a url, download it to tmpdir
                  found = self._download_url(scheme.group(1), spec, tmpdir)
                  base, fragment = egg_info_for_url(spec)
                  if base.endswith('.py'):
                      found = self.gen_setup(found, fragment, tmpdir)
                  return found
              elif os.path.exists(spec):
                  # Existing file or directory, just return it
                  return spec
              else:
                  spec = parse_requirement_arg(spec)
          return getattr(self.fetch_distribution(spec, tmpdir), 'location', None)
function_tokens: def download ( self , spec , tmpdir ) : if not isinstance ( spec , Requirement ) : scheme = URL_SCHEME ( spec ) if scheme : # It's a url, download it to tmpdir found = self . _download_url ( scheme . group ( 1 ) , spec , tmpdir ) base , fragment = egg_info_for_url ( spec ) if base . endswith ( '.py' ) : found = self . gen_setup ( found , fragment , tmpdir ) return found elif os . path . exists ( spec ) : # Existing file or directory, just return it return spec else : spec = parse_requirement_arg ( spec ) return getattr ( self . fetch_distribution ( spec , tmpdir ) , 'location' , None )