code: def test_auto_if_wanted_data_transfer_path_restriction(path=None):
      path = Path(path)
      ds_a = Dataset(path / "a").create()
      ds_a_sub0 = ds_a.create("sub0")
      ds_a_sub1 = ds_a.create("sub1")
  
      for ds in [ds_a, ds_a_sub0, ds_a_sub1]:
          (ds.pathobj / "sec.dat").write_text("sec")
          (ds.pathobj / "reg.dat").write_text("reg")
      ds_a.save(recursive=True)
  
      ds_a.create_sibling(
          str(path / "b"),
          name="b",
          annex_wanted="not metadata=distribution-restrictions=*",
          recursive=True,
      )
      for ds in [ds_a, ds_a_sub0, ds_a_sub1]:
          ds.repo.set_metadata(
              add={"distribution-restrictions": "doesntmatter"},
              files=["sec.dat"],
          )
  
      # wanted-triggered --auto can be restricted to subdataset...
      res = ds_a.push(
          to="b", path="sub0", data="auto-if-wanted", recursive=True
      )
      assert_not_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a.pathobj / "reg.dat"),
      )
      assert_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a_sub0.pathobj / "reg.dat"),
      )
      assert_not_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a_sub0.pathobj / "sec.dat"),
      )
      assert_not_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a_sub1.pathobj / "reg.dat"),
      )
  
      # ... and to a wanted file.
      res = ds_a.push(
          to="b", path="reg.dat", data="auto-if-wanted", recursive=True
      )
      assert_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a.pathobj / "reg.dat"),
      )
      assert_not_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a_sub1.pathobj / "reg.dat"),
      )
  
      # But asking to transfer a file does not do it if the remote has a
      # wanted setting and doesn't want it.
      res = ds_a.push(
          to="b", path="sec.dat", data="auto-if-wanted", recursive=True
      )
      assert_not_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a.pathobj / "sec.dat"),
      )
  
      res = ds_a.push(
          to="b", path="sec.dat", data="anything", recursive=True
      )
      assert_in_results(
          res,
          action="copy",
          target="b",
          status="ok",
          path=str(ds_a.pathobj / "sec.dat"),
      )
  
imports: import logging
  import os
  import pytest
  from datalad.core.distributed.clone import Clone
  from datalad.core.distributed.push import Push
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import IncompleteResultsError, InsufficientArgumentsError
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import get_local_file_url
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_false, assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, eq_, known_failure_githubci_osx, known_failure_githubci_win, neq_, ok_, ok_file_has_content, serve_path_via_http, skip_if_adjusted_branch, skip_if_on_windows, skip_ssh, slow, swallow_logs, with_tempfile, with_tree
  from datalad.utils import Path, chpwd, path_startswith, swallow_outputs
label_desc: Use image node_id 16 for calling a global function with example usage: test_auto_if_wanted_data_transfer_path_restriction(path) without return types