Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
449e18f4
Kaydet (Commit)
449e18f4
authored
Ara 28, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add documentation for shutil module.
üst
cd058539
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
lib.tex
Doc/lib/lib.tex
+1
-0
libshutil.tex
Doc/lib/libshutil.tex
+100
-0
No files found.
Doc/lib/lib.tex
Dosyayı görüntüle @
449e18f4
...
...
@@ -127,6 +127,7 @@ add new extensions to Python and how to embed it in other applications.
\input
{
liberrno
}
\input
{
libglob
}
\input
{
libfnmatch
}
\input
{
libshutil
}
\input
{
liblocale
}
\input
{
libsomeos
}
% Optional Operating System Services
...
...
Doc/lib/libshutil.tex
0 → 100644
Dosyayı görüntüle @
449e18f4
\section
{
\module
{
shutil
}
---
High-level file operations.
}
\declaremodule
{
standard
}{
shutil
}
\sectionauthor
{
Fred L. Drake, Jr.
}{
fdrake@acm.org
}
% partly based on the docstrings
The
\module
{
shutil
}
module offers a number of high-level operations on
files and collections of files. In particular, functions are provided
which support file copying and removal.
\strong
{
Caveat:
}
On MacOS, the resource fork and other metadata are
not used. For file copies, this means that resources will be lost and
file type and creator codes will not be correct.
\begin{funcdesc}
{
copyfile
}{
src, dst
}
Copy the contents of
\var
{
src
}
to
\var
{
dst
}
. If
\var
{
dst
}
exists,
it will be replaced, otherwise it will be created.
\end{funcdesc}
\begin{funcdesc}
{
copymode
}{
src, dst
}
Copy the permission bits from
\var
{
src
}
to
\var
{
dst
}
. The file
contents, owner, and group are unaffected.
\end{funcdesc}
\begin{funcdesc}
{
copystat
}{
src, dst
}
Copy the permission bits, last access time, and last modification
time from
\var
{
src
}
to
\var
{
dst
}
. The file contents, owner, and
group are unaffected.
\end{funcdesc}
\begin{funcdesc}
{
copy
}{
src, dst
}
Copy the file
\var
{
src
}
to the file or directory
\var
{
dst
}
. If
\var
{
dst
}
is a directory, a file with the same basename as
\var
{
src
}
is created (or overwritten) in the directory specified. Permission
bits are copied.
\end{funcdesc}
\begin{funcdesc}
{
copy2
}{
src, dst
}
Similar to
\function
{
copy()
}
, but last access time and last
modification time are copied as well. This is similar to the
\UNIX
{}
command
\program
{
cp -p
}
.
\end{funcdesc}
\begin{funcdesc}
{
copytree
}{
src, dst
\optional
{
, symlinks
}}
Recursively copy an entire directory tree rooted at
\var
{
src
}
. The
destination directory, named by
\var
{
dst
}
, must not already exist;
it will be created. Individual files are copied using
\function
{
copy2()
}
. If
\var
{
symlinks
}
is true, symbolic links in
the source tree are represented as symbolic links in the new tree;
if false or omitted, the contents of the linked files are copied to
the new tree. Errors are reported to standard output.
The source code for this should be considered an example rather than
a tool.
\end{funcdesc}
\begin{funcdesc}
{
rmtree
}{
path
\optional
{
, ignore
_
errors
\optional
{
, onerror
}}}
Delete an entire directory tree. If
\var
{
ignore
_
errors
}
is true,
errors will be ignored; if false or omitted, errors are handled by
calling a handler specified by
\var
{
onerror
}
or raise an exception.
If
\var
{
onerror
}
is provided, it must be a callable that accepts
three parameters:
\var
{
function
}
,
\var
{
path
}
, and
\var
{
excinfo
}
.
The first parameter,
\var
{
function
}
, is the function which raised
the exception; it will be
\function
{
os.remove()
}
or
\function
{
os.rmdir()
}
. The second parameter,
\var
{
path
}
, will be
the path name passed to
\var
{
function
}
. The third parameter,
\var
{
excinfo
}
, will be the exception information return by
\function
{
sys.exc
_
info()
}
. Exceptions raised by
\var
{
onerror
}
will
not be caught.
\end{funcdesc}
\subsection
{
Example
\label
{
shutil-example
}}
This example is the implementation of the
\function
{
copytree()
}
function, described above, with the docstring omitted.
\begin{verbatim}
def copytree(src, dst, symlinks=0):
names = os.listdir(src)
os.mkdir(dst)
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
if symlinks and os.path.islink(srcname):
linkto = os.readlink(srcname)
os.symlink(linkto, dstname)
elif os.path.isdir(srcname):
copytree(srcname, dstname)
else:
copy2(srcname, dstname)
# XXX What about devices, sockets etc.?
except (IOError, os.error), why:
print "Can't copy
%s to %s: %s" % (`srcname`, `dstname`, str(why))
\end{verbatim}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment