code: def postclonecfg_ria(ds, props, remote="origin"):
      """Configure a dataset freshly cloned from a RIA store"""
      repo = ds.repo
  
      def get_uuid_from_store(store_url):
          # First figure whether we cloned via SSH, HTTP or local path and then
          # get that config file the same way:
          config_content = None
          scheme = store_url.split(":", 1)[0]
          if scheme in ["http", "https"]:
              try:
                  config_content = download_url(
                      "{}{}config".format(
                          store_url,
                          "/" if not store_url.endswith("/") else "",
                      )
                  )
              except DownloadError as e:
                  ce = CapturedException(e)
                  lgr.debug(
                      "Failed to get config file from source:\n%s", ce
                  )
          elif scheme == "ssh":
              # TODO: switch the following to proper command abstraction:
              # SSHRemoteIO ignores the path part ATM. No remote CWD! (To be
              # changed with command abstractions). So we need to get that part to
              # have a valid path to the remote's config file:
              cfg_path = PurePosixPath(URL(store_url).path) / "config"
              io = SSHRemoteIO(store_url)
              try:
                  config_content = io.read_file(cfg_path)
              except RIARemoteError as e:
                  ce = CapturedException(e)
                  lgr.debug(
                      "Failed to get config file from source: %s", ce
                  )
  
          elif scheme == "file":
              # TODO: switch the following to proper command abstraction:
              io = LocalIO()
              cfg_path = Path(URL(store_url).localpath) / "config"
              try:
                  config_content = io.read_file(cfg_path)
              except (RIARemoteError, OSError) as e:
                  ce = CapturedException(e)
                  lgr.debug(
                      "Failed to get config file from source: %s", ce
                  )
          else:
              lgr.debug(
                  "Unknown URL-Scheme %s in %s. Can handle SSH, HTTP or "
                  "FILE scheme URLs.",
                  scheme,
                  props["source"],
              )
  
          # And read it
          uuid = None
          if config_content:
              runner = GitWitlessRunner()
              try:
                  # "git config -f -" can read from stdin; this spares us a
                  # temp file
                  result = runner.run(
                      [
                          "git",
                          "config",
                          "-f",
                          "-",
                          "datalad.ora-remote.uuid",
                      ],
                      stdin=config_content.encode(encoding="utf-8"),
                      protocol=StdOutCapture,
                  )
                  uuid = result["stdout"].strip()
              except CommandError as e:
                  ce = CapturedException(e)
                  # doesn't contain what we are looking for
                  lgr.debug(
                      "Found no UUID for ORA special remote at "
                      "'%s' (%s)",
                      remote,
                      ce,
                  )
  
          return uuid
  
      # chances are that if this dataset came from a RIA store, its subdatasets
      # may live there too. Place a subdataset source candidate config that makes
      # get probe this RIA store when obtaining subdatasets
      ria_store_url = props["source"].split("#", maxsplit=1)[0]
      ds.config.set(
          # we use the label 'origin' for this candidate in order to not have to
          # generate a complicated name from the actual source specification.
          # we pick a cost of 200 to sort it before datalad's default candidates
          # for non-RIA URLs, because they prioritize hierarchical layouts that
          # cannot be found in a RIA store
          "datalad.get.subdataset-source-candidate-200origin",
          # use the entire original URL, up to the fragment + plus dataset ID
          # placeholder, this should make things work with any store setup we
          # support (paths, ports, ...)
          ria_store_url + "#{id}",
          scope="local",
      )
  
      # setup publication dependency, if a corresponding special remote exists
      # and was enabled (there could be RIA stores that actually only have repos)
      # make this function be a generator
      ora_remotes = [
          s
          for s in ds.siblings("query", result_renderer="disabled")
          if s.get("annex-externaltype") == "ora"
      ]
      # get full special remotes' config for access to stored URL
      srs = (
          repo.get_special_remotes()
          if hasattr(repo, "get_special_remotes")
          else dict()
      )
  
      has_only_disabled_ora = not ora_remotes and any(
          r.get("externaltype") == "ora" for r in srs.values()
      )
  
      def match_in_urls(special_remote_cfg, url_to_match):
          # Figure whether either `url` or `push-url` in an ORA remote's config
          # match a given URL (to a RIA store).
          return special_remote_cfg["url"].startswith(url_to_match) or (
              special_remote_cfg["push-url"].startswith(url_to_match)
              if "push-url" in special_remote_cfg
              else False
          )
  
      no_enabled_ora_matches_url = all(
          not match_in_urls(srs[r["annex-uuid"]], ria_store_url)
          for r in ora_remotes
      )
  
      if has_only_disabled_ora or no_enabled_ora_matches_url:
          # No ORA remote autoenabled, but configuration known about at least one,
          # or enabled ORA remotes seem to not match clone URL.
          # Let's check the remote's config for datalad.ora-remote.uuid as stored
          # by create-sibling-ria and try enabling that one.
          lgr.debug(
              "Found no autoenabled ORA special remote. Trying to look it "
              "up in source config ..."
          )
  
          org_uuid = get_uuid_from_store(props["giturl"])
  
          # Now, enable it. If annex-init didn't fail to enable it as stored, we
          # wouldn't end up here, so enable with store URL as suggested by the URL
          # we cloned from.
          if org_uuid:
              if org_uuid in srs.keys():
                  # TODO: - Double-check autoenable value and only do this when
                  #         true?
                  #       - What if still fails? -> Annex shouldn't change config
                  #         in that case
  
                  # we only need the store:
                  new_url = props["source"].split("#")[0]
                  try:
                      # local config to overwrite committed URL
                      repo.config.set(
                          f"remote.{srs[org_uuid]['name']}.ora-url",
                          new_url,
                          scope="local",
                      )
                      repo.enable_remote(srs[org_uuid]["name"])
                      lgr.info(
                          "Reconfigured %s for %s",
                          srs[org_uuid]["name"],
                          new_url,
                      )
                      # update ora_remotes for considering publication dependency
                      # below
                      ora_remotes = [
                          s
                          for s in ds.siblings(
                              "query", result_renderer="disabled"
                          )
                          if s.get("annex-externaltype", None) == "ora"
                      ]
                  except CommandError as e:
                      ce = CapturedException(e)
                      lgr.debug(
                          "Failed to reconfigure ORA special remote: %s",
                          ce,
                      )
                      repo.config.unset(
                          f"remote.{srs[org_uuid]['name']}.ora-url",
                          scope="local",
                      )
              else:
                  lgr.debug(
                      "Unknown ORA special remote uuid at '%s': %s",
                      remote,
                      org_uuid,
                  )
  
      # Set publication dependency for `remote` on the respective ORA remote:
      if ora_remotes:
          url_matching_remotes = [
              r
              for r in ora_remotes
              if srs[r["annex-uuid"]]["url"] == ria_store_url
          ]
  
          if len(url_matching_remotes) == 1:
              # We have exactly one ORA remote with the same store URL we used for
              # cloning (includes previously reconfigured remote).
              # Set publication dependency:
              yield from ds.siblings(
                  "configure",
                  name=remote,
                  publish_depends=url_matching_remotes[0]["name"],
                  result_filter=None,
                  result_renderer="disabled",
              )
  
          elif not url_matching_remotes:
              # No matches but we have successfully autoenabled ORA remotes. Could
              # be the same store accessed by different method (cloning via HTTP
              # but special remote access via SSH). We can confidently set
              # publication dependency if the store knows the UUID.
              org_uuid = get_uuid_from_store(props["giturl"])
              uuid_matching_remotes = [
                  r for r in ora_remotes if r["annex-uuid"] == org_uuid
              ]
              if uuid_matching_remotes:
                  # Multiple uuid matches are actually possible via same-as.
                  # However, in that case we can't decide which one is supposed to
                  # be used with publishing to `remote`.
                  if len(uuid_matching_remotes) == 1:
                      yield from ds.siblings(
                          "configure",
                          name=remote,
                          publish_depends=uuid_matching_remotes[0][
                              "name"
                          ],
                          result_filter=None,
                          result_renderer="disabled",
                      )
                  else:
                      lgr.warning(
                          "Found multiple matching ORA remotes. Couldn't decide "
                          "which one publishing to '%s' should depend on: %s."
                          " Consider running 'datalad siblings configure -s "
                          "%s --publish-depends ORAREMOTENAME' to set "
                          "publication dependency manually.",
                          remote,
                          [r["name"] for r in uuid_matching_remotes],
                          remote,
                      )
  
          else:
              # We have multiple ORA remotes with the same store URL we cloned
              # from.
              lgr.warning(
                  "Found multiple matching ORA remotes. Couldn't decide "
                  "which one publishing to '%s' should depend on: %s."
                  " Consider running 'datalad siblings configure -s "
                  "%s --publish-depends ORAREMOTENAME' to set "
                  "publication dependency manually.",
                  remote,
                  [r["name"] for r in url_matching_remotes],
                  remote,
              )
  
imports: import logging
  import re
  from os.path import expanduser
  from pathlib import Path
  from typing import Dict, List, Tuple
  from urllib.parse import unquote
  from datalad.cmd import CommandError, GitWitlessRunner, StdOutCapture
  from datalad.config import ConfigManager
  from datalad.distributed.ora_remote import LocalIO, RIARemoteError, SSHRemoteIO
  from datalad.distribution.dataset import Dataset
  from datalad.distribution.utils import _get_flexible_source_candidates
  from datalad.dochelpers import single_or_plural
  from datalad.log import log_progress
  from datalad.runner.exception import CommandError
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CapturedException, DownloadError
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import RI, SSHRI, URL, DataLadRI, download_url, get_local_file_url, is_url
  from datalad.support.strings import get_replacement_dict
  from datalad.utils import Path, PurePosixPath, ensure_bool, ensure_list, make_tempfile, rmtree
label_desc: Use image node_id 2 for calling a global function with example usage: postclonecfg_ria(ds, props, remote) and returns: uuid, unknown