Commit aa1e85c6 authored by Johannes Gijsbers's avatar Johannes Gijsbers

Patch #1094015:

* Use os.makedirs() instead os.mkdir(). (bug #975763)
* Use copystat() to copy directory bits (bug #1048878)
parent 099fe2f5
...@@ -67,8 +67,10 @@ file type and creator codes will not be correct. ...@@ -67,8 +67,10 @@ file type and creator codes will not be correct.
\begin{funcdesc}{copytree}{src, dst\optional{, symlinks}} \begin{funcdesc}{copytree}{src, dst\optional{, symlinks}}
Recursively copy an entire directory tree rooted at \var{src}. The Recursively copy an entire directory tree rooted at \var{src}. The
destination directory, named by \var{dst}, must not already exist; destination directory, named by \var{dst}, must not already exist;
it will be created. Individual files are copied using it will be created as well as missing parent directories.
\function{copy2()}. If \var{symlinks} is true, symbolic links in Permissions and times of directories are copied with \function{copystat()},
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; 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 if false or omitted, the contents of the linked files are copied to
the new tree. If exception(s) occur, an Error is raised the new tree. If exception(s) occur, an Error is raised
...@@ -76,8 +78,14 @@ file type and creator codes will not be correct. ...@@ -76,8 +78,14 @@ file type and creator codes will not be correct.
The source code for this should be considered an example rather than The source code for this should be considered an example rather than
a tool. a tool.
\versionchanged[Error is raised if any exceptions occur during copying,
rather than printing a message]{2.3} \versionchanged[Error is raised if any exceptions occur during copying,
rather than printing a message]{2.3}
\versionchanged[Create intermediate directories needed to create \var{dst},
rather than raising an error. Copy permissions and times of directories using
\function{copystat()}]{2.5}
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{rmtree}{path\optional{, ignore_errors\optional{, onerror}}} \begin{funcdesc}{rmtree}{path\optional{, ignore_errors\optional{, onerror}}}
......
...@@ -108,7 +108,8 @@ def copytree(src, dst, symlinks=False): ...@@ -108,7 +108,8 @@ def copytree(src, dst, symlinks=False):
""" """
names = os.listdir(src) names = os.listdir(src)
os.mkdir(dst) os.makedirs(dst)
copystat(src, dst)
errors = [] errors = []
for name in names: for name in names:
srcname = os.path.join(src, name) srcname = os.path.join(src, name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment