MCPcopy
hub / github.com/treeverse/dvc / _info

Method _info

dvc/fs/dvc.py:447–490  ·  view source on GitHub ↗
(  # noqa: C901
        self, key, path, ignore_subrepos=True, check_ignored=True
    )

Source from the content-addressed store, hash-verified

445 return self._info(key, path, ignore_subrepos=ignore_subrepos)
446
447 def _info( # noqa: C901
448 self, key, path, ignore_subrepos=True, check_ignored=True
449 ):
450 repo, dvc_fs, subkey = self._get_subrepo_info(key)
451
452 dvc_info = None
453 if dvc_fs:
454 try:
455 dvc_info = dvc_fs.fs.index.info(subkey)
456 dvc_path = _get_dvc_path(dvc_fs, subkey)
457 dvc_info["name"] = dvc_path
458 except KeyError:
459 pass
460
461 fs_info = None
462 fs = self.repo.fs
463 fs_path = self._from_key(key)
464 try:
465 fs_info = fs.info(fs_path)
466 if check_ignored and repo.dvcignore.is_ignored(
467 fs, fs_path, ignore_subrepos=ignore_subrepos
468 ):
469 fs_info = None
470 except (FileNotFoundError, NotADirectoryError):
471 if not dvc_info:
472 raise
473
474 # NOTE: if some parent in fs_path turns out to be a file, it means
475 # that the whole repofs branch doesn't exist.
476 if dvc_info and not fs_info:
477 for parent in fs.parents(fs_path):
478 try:
479 if fs.info(parent)["type"] != "directory":
480 dvc_info = None
481 break
482 except FileNotFoundError:
483 continue
484
485 if not dvc_info and not fs_info:
486 raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
487
488 info = _merge_info(repo, subkey, fs_info, dvc_info)
489 info["name"] = path
490 return info
491
492 def get(
493 self,

Callers 1

infoMethod · 0.95

Calls 7

_get_subrepo_infoMethod · 0.95
_from_keyMethod · 0.95
_get_dvc_pathFunction · 0.85
_merge_infoFunction · 0.85
is_ignoredMethod · 0.80
parentsMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected