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

Class Path

Lib/pathlib/__init__.py:621–1282  ·  view source on GitHub ↗

PurePath subclass that can make system calls. Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiat

Source from the content-addressed store, hash-verified

619
620
621class Path(PurePath):
622 """PurePath subclass that can make system calls.
623
624 Path represents a filesystem path but unlike PurePath, also offers
625 methods to do system calls on path objects. Depending on your system,
626 instantiating a Path will return either a PosixPath or a WindowsPath
627 object. You can also instantiate a PosixPath or WindowsPath directly,
628 but cannot instantiate a WindowsPath on a POSIX system or vice versa.
629 """
630 __slots__ = ('_info',)
631
632 def __new__(cls, *args, **kwargs):
633 if cls is Path:
634 cls = WindowsPath if os.name == 'nt' else PosixPath
635 return object.__new__(cls)
636
637 @property
638 def info(self):
639 """
640 A PathInfo object that exposes the file type and other file attributes
641 of this path.
642 """
643 try:
644 return self._info
645 except AttributeError:
646 self._info = PathInfo(self)
647 return self._info
648
649 def stat(self, *, follow_symlinks=True):
650 """
651 Return the result of the stat() system call on this path, like
652 os.stat() does.
653 """
654 return os.stat(self, follow_symlinks=follow_symlinks)
655
656 def lstat(self):
657 """
658 Like stat(), except if the path points to a symlink, the symlink's
659 status information is returned, rather than its target's.
660 """
661 return os.lstat(self)
662
663 def exists(self, *, follow_symlinks=True):
664 """
665 Whether this path exists.
666
667 This method normally follows symlinks; to check whether a symlink exists,
668 add the argument follow_symlinks=False.
669 """
670 if follow_symlinks:
671 return os.path.exists(self)
672 return os.path.lexists(self)
673
674 def is_dir(self, *, follow_symlinks=True):
675 """
676 Whether this path is a directory.
677 """
678 if follow_symlinks:

Callers 15

compile_fileFunction · 0.90
test_issue44061Method · 0.90
test_traceback.pyFile · 0.90
make_moduleMethod · 0.90
__init__Method · 0.90
find_pyMethod · 0.90
py_iniMethod · 0.90
scriptMethod · 0.90
test_versionMethod · 0.90
test_list_pathsMethod · 0.90
test_search_pathMethod · 0.90
test_search_path_exeMethod · 0.90

Calls 2

sliceClass · 0.85
hasattrFunction · 0.85

Tested by 15

test_issue44061Method · 0.72
make_moduleMethod · 0.72
__init__Method · 0.72
find_pyMethod · 0.72
py_iniMethod · 0.72
scriptMethod · 0.72
test_versionMethod · 0.72
test_list_pathsMethod · 0.72
test_search_pathMethod · 0.72
test_search_path_exeMethod · 0.72
test_uri_windowsMethod · 0.72