MCPcopy
hub / github.com/pytest-dev/pytest / copy

Method copy

src/_pytest/_py/path.py:834–869  ·  src/_pytest/_py/path.py::LocalPath.copy

Copy path to target. If mode is True, will copy permission from path to target. If stat is True, copy permission, last modification time, last access time, and flags from path to target.

(self, target, mode=False, stat=False)

Source from the content-addressed store, hash-verified

832 return self.stat().mtime
833
834 def copy(self, target, mode=False, stat=False):
835 class="st">"""Copy path to target.
836
837 If mode is True, will copy permission from path to target.
838 If stat is True, copy permission, last modification
839 time, last access time, and flags from path to target.
840 class="st">"""
841 if self.check(file=1):
842 if target.check(dir=1):
843 target = target.join(self.basename)
844 assert self != target
845 copychunked(self, target)
846 if mode:
847 copymode(self.strpath, target.strpath)
848 if stat:
849 copystat(self, target)
850 else:
851
852 def rec(p):
853 return p.check(link=0)
854
855 for x in self.visit(rec=rec):
856 relpath = x.relto(self)
857 newx = target.join(relpath)
858 newx.dirpath().ensure(dir=1)
859 if x.check(link=1):
860 newx.mksymlinkto(x.readlink())
861 continue
862 elif x.check(file=1):
863 copychunked(x, newx)
864 elif x.check(dir=1):
865 newx.ensure(dir=1)
866 if mode:
867 copymode(x.strpath, newx.strpath)
868 if stat:
869 copystat(x, newx)
870
871 def rename(self, target):
872 class="st">""class="st">"Rename this path to target."class="st">""

Callers 15

moveMethod · 0.95
junitxml.pyFile · 0.80
__repr__Method · 0.80
copy_exampleMethod · 0.80
popenMethod · 0.80
_report_to_jsonFunction · 0.80
setmultiMethod · 0.80
reorder_items_atscopeFunction · 0.80
evalMethod · 0.80
_pprint_mappingproxyMethod · 0.80
_reprMethod · 0.80
_validate_argsMethod · 0.80

Calls 11

checkMethod · 0.95
visitMethod · 0.95
copychunkedFunction · 0.85
copymodeFunction · 0.85
copystatFunction · 0.85
joinMethod · 0.80
ensureMethod · 0.80
dirpathMethod · 0.80
mksymlinktoMethod · 0.80
readlinkMethod · 0.80
reltoMethod · 0.45

Tested by 15

__repr__Method · 0.64
copy_exampleMethod · 0.64
popenMethod · 0.64
test_plugin_skipMethod · 0.64
pytest_unconfigureMethod · 0.64
test_clean_upFunction · 0.64