mirror of
https://github.com/python/cpython.git
synced 2025-09-17 22:20:23 +00:00
Reformat docstrings.
Standardize use of whitespace on function calls.
This commit is contained in:
parent
4a751580ca
commit
9e3dc4e928
1 changed files with 60 additions and 62 deletions
|
@ -18,11 +18,11 @@ _copy_action = { None: 'copying',
|
||||||
|
|
||||||
def _copy_file_contents (src, dst, buffer_size=16*1024):
|
def _copy_file_contents (src, dst, buffer_size=16*1024):
|
||||||
"""Copy the file 'src' to 'dst'; both must be filenames. Any error
|
"""Copy the file 'src' to 'dst'; both must be filenames. Any error
|
||||||
opening either file, reading from 'src', or writing to 'dst',
|
opening either file, reading from 'src', or writing to 'dst', raises
|
||||||
raises DistutilsFileError. Data is read/written in chunks of
|
DistutilsFileError. Data is read/written in chunks of 'buffer_size'
|
||||||
'buffer_size' bytes (default 16k). No attempt is made to handle
|
bytes (default 16k). No attempt is made to handle anything apart from
|
||||||
anything apart from regular files."""
|
regular files.
|
||||||
|
"""
|
||||||
# Stolen from shutil module in the standard library, but with
|
# Stolen from shutil module in the standard library, but with
|
||||||
# custom error-handling added.
|
# custom error-handling added.
|
||||||
|
|
||||||
|
@ -74,31 +74,29 @@ def copy_file (src, dst,
|
||||||
verbose=0,
|
verbose=0,
|
||||||
dry_run=0):
|
dry_run=0):
|
||||||
|
|
||||||
"""Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src'
|
"""Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
|
||||||
is copied there with the same name; otherwise, it must be a
|
copied there with the same name; otherwise, it must be a filename. (If
|
||||||
filename. (If the file exists, it will be ruthlessly clobbered.)
|
the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
|
||||||
If 'preserve_mode' is true (the default), the file's mode (type
|
is true (the default), the file's mode (type and permission bits, or
|
||||||
and permission bits, or whatever is analogous on the current
|
whatever is analogous on the current platform) is copied. If
|
||||||
platform) is copied. If 'preserve_times' is true (the default),
|
'preserve_times' is true (the default), the last-modified and
|
||||||
the last-modified and last-access times are copied as well. If
|
last-access times are copied as well. If 'update' is true, 'src' will
|
||||||
'update' is true, 'src' will only be copied if 'dst' does not
|
only be copied if 'dst' does not exist, or if 'dst' does exist but is
|
||||||
exist, or if 'dst' does exist but is older than 'src'. If
|
older than 'src'. If 'verbose' is true, then a one-line summary of the
|
||||||
'verbose' is true, then a one-line summary of the copy will be
|
copy will be printed to stdout.
|
||||||
printed to stdout.
|
|
||||||
|
|
||||||
'link' allows you to make hard links (os.link) or symbolic links
|
'link' allows you to make hard links (os.link) or symbolic links
|
||||||
(os.symlink) instead of copying: set it to "hard" or "sym"; if it
|
(os.symlink) instead of copying: set it to "hard" or "sym"; if it is
|
||||||
is None (the default), files are copied. Don't set 'link' on
|
None (the default), files are copied. Don't set 'link' on systems that
|
||||||
systems that don't support it: 'copy_file()' doesn't check if
|
don't support it: 'copy_file()' doesn't check if hard or symbolic
|
||||||
hard or symbolic linking is available.
|
linking is available.
|
||||||
|
|
||||||
Under Mac OS, uses the native file copy function in macostools;
|
Under Mac OS, uses the native file copy function in macostools; on
|
||||||
on other systems, uses '_copy_file_contents()' to copy file
|
other systems, uses '_copy_file_contents()' to copy file contents.
|
||||||
contents.
|
|
||||||
|
|
||||||
Return the name of the destination file, whether it was actually
|
|
||||||
copied or not."""
|
|
||||||
|
|
||||||
|
Return the name of the destination file, whether it was actually copied
|
||||||
|
or not.
|
||||||
|
"""
|
||||||
# XXX if the destination file already exists, we clobber it if
|
# XXX if the destination file already exists, we clobber it if
|
||||||
# copying, but blow up if linking. Hmmm. And I don't know what
|
# copying, but blow up if linking. Hmmm. And I don't know what
|
||||||
# macostools.copyfile() does. Should definitely be consistent, and
|
# macostools.copyfile() does. Should definitely be consistent, and
|
||||||
|
@ -180,13 +178,13 @@ def move_file (src, dst,
|
||||||
verbose=0,
|
verbose=0,
|
||||||
dry_run=0):
|
dry_run=0):
|
||||||
|
|
||||||
"""Move a file 'src' to 'dst'. If 'dst' is a directory, the file
|
"""Move a file 'src' to 'dst'. If 'dst' is a directory, the file will
|
||||||
will be moved into it with the same name; otherwise, 'src' is
|
be moved into it with the same name; otherwise, 'src' is just renamed
|
||||||
just renamed to 'dst'. Return the new full name of the file.
|
to 'dst'. Return the new full name of the file.
|
||||||
|
|
||||||
Handles cross-device moves on Unix using
|
|
||||||
'copy_file()'. What about other systems???"""
|
|
||||||
|
|
||||||
|
Handles cross-device moves on Unix using 'copy_file()'. What about
|
||||||
|
other systems???
|
||||||
|
"""
|
||||||
from os.path import exists, isfile, isdir, basename, dirname
|
from os.path import exists, isfile, isdir, basename, dirname
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
|
@ -242,8 +240,8 @@ def move_file (src, dst,
|
||||||
|
|
||||||
def write_file (filename, contents):
|
def write_file (filename, contents):
|
||||||
"""Create a file with the specified name and write 'contents' (a
|
"""Create a file with the specified name and write 'contents' (a
|
||||||
sequence of strings without line terminators) to it."""
|
sequence of strings without line terminators) to it.
|
||||||
|
"""
|
||||||
f = open(filename, "w")
|
f = open(filename, "w")
|
||||||
for line in contents:
|
for line in contents:
|
||||||
f.write(line + "\n")
|
f.write(line + "\n")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue