MCPcopy Index your code
hub / github.com/python/cpython / is_file

Method is_file

Lib/pathlib/__init__.py:690–707  ·  view source on GitHub ↗

Whether this path is a regular file.

(self, *, follow_symlinks=True)

Source from the content-addressed store, hash-verified

688 return S_ISDIR(st.st_mode)
689
690 def is_file(self, *, follow_symlinks=True):
691 """Whether this path is a regular file."""
692 if self._entry:
693 try:
694 return self._entry.is_file(follow_symlinks=follow_symlinks)
695 except OSError:
696 return False
697 if follow_symlinks:
698 if self._stat_result is _STAT_RESULT_ERROR:
699 return False
700 else:
701 if self._lstat_result is _STAT_RESULT_ERROR:
702 return False
703 try:
704 st = self._stat(follow_symlinks=follow_symlinks)
705 except (OSError, ValueError):
706 return False
707 return S_ISREG(st.st_mode)
708
709 def is_symlink(self):
710 """Whether this path is a symbolic link."""

Callers

nothing calls this directly

Calls 3

_statMethod · 0.95
S_ISREGFunction · 0.90
is_fileMethod · 0.45

Tested by

no test coverage detected