MCPcopy Index your code
hub / github.com/RustPython/RustPython / DirEntryInfo

Class DirEntryInfo

Lib/pathlib/_os.py:487–530  ·  view source on GitHub ↗

Implementation of pathlib.types.PathInfo that provides status information by querying a wrapped os.DirEntry object. Don't try to construct it yourself.

Source from the content-addressed store, hash-verified

485
486
487class DirEntryInfo(_PathInfoBase):
488 """Implementation of pathlib.types.PathInfo that provides status
489 information by querying a wrapped os.DirEntry object. Don't try to
490 construct it yourself."""
491 __slots__ = ('_entry',)
492
493 def __init__(self, entry):
494 super().__init__(entry.path)
495 self._entry = entry
496
497 def _stat(self, *, follow_symlinks=True, ignore_errors=False):
498 try:
499 return self._entry.stat(follow_symlinks=follow_symlinks)
500 except OSError:
501 if not ignore_errors:
502 raise
503 return None
504
505 def exists(self, *, follow_symlinks=True):
506 """Whether this path exists."""
507 if not follow_symlinks:
508 return True
509 return self._stat(ignore_errors=True) is not None
510
511 def is_dir(self, *, follow_symlinks=True):
512 """Whether this path is a directory."""
513 try:
514 return self._entry.is_dir(follow_symlinks=follow_symlinks)
515 except OSError:
516 return False
517
518 def is_file(self, *, follow_symlinks=True):
519 """Whether this path is a regular file."""
520 try:
521 return self._entry.is_file(follow_symlinks=follow_symlinks)
522 except OSError:
523 return False
524
525 def is_symlink(self):
526 """Whether this path is a symbolic link."""
527 try:
528 return self._entry.is_symlink()
529 except OSError:
530 return False

Callers 1

_from_dir_entryMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected