code: def _get_flexible_source_candidates(
      src, base_url=None, alternate_suffix=True
  ):
      """Get candidates to try cloning from.
  
      Primarily to mitigate the problem that git doesn't append /.git
      while cloning from non-bare repos over dummy protocol (http*).  Also to
      simplify creation of urls whenever base url and relative path within it
      provided
  
      Parameters
      ----------
      src : string or RI
        Full or relative (then considered within base_url if provided) path
      base_url : string or RI, optional
      alternate_suffix : bool
        Whether to generate URL candidates with and without '/.git' suffixes.
  
      Returns
      -------
      candidates : list of str
        List of RIs (path, url, ssh targets) to try to install from
      """
      candidates = []
  
      ri = RI(src)
      if isinstance(ri, PathRI) and not isabs(ri.path) and base_url:
          ri = RI(base_url)
          if ri.path.endswith("/.git"):
              base_path = ri.path[:-5]
              base_suffix = ".git"
          else:
              base_path = ri.path
              base_suffix = ""
          if isinstance(ri, PathRI):
              # this is a path, so stay native
              ri.path = normpath(opj(base_path, src, base_suffix))
          else:
              # we are handling a URL, use POSIX path conventions
              ri.path = posixpath.normpath(
                  posixpath.join(base_path, src, base_suffix)
              )
  
      src = str(ri)
  
      candidates.append(src)
      if alternate_suffix and isinstance(ri, URL):
          if ri.scheme in {"http", "https"}:
              # additionally try to consider .git:
              if not src.rstrip("/").endswith("/.git"):
                  candidates.append("{0}/.git".format(src.rstrip("/")))
  
      return candidates
  
imports: import logging
  from os.path import isabs, join, normpath
  import posixpath
  from datalad.log import log_progress
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.network import PathRI, RI, URL
label_desc: Use image node_id 1 for calling a global function with example usage: _get_flexible_source_candidates(src, base_url, alternate_suffix) and returns: candidates