p!ranha?
Server IP : 103.169.32.36  /  Your IP : 216.73.217.13
Web Server : Apache
System : Linux web.dpmptsp 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 5.6.40
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib64/python2.7/distutils/

Upload File :
Curr3nt_D!r [ Writeable ] D0cum3nt_r0Ot [ Writeable ]

 
Command :
Current File : /lib64/python2.7/distutils/file_util.py
"""distutils.file_util

Utility functions for operating on single files.
"""

__revision__ = "$Id$"

import os
from distutils.errors import DistutilsFileError
from distutils import log

# for generating verbose output in 'copy_file()'
_copy_action = {None: 'copying',
                'hard': 'hard linking',
                'sym': 'symbolically linking'}


def _copy_file_contents(src, dst, buffer_size=16*1024):
    """Copy the file 'src' to 'dst'.

    Both must be filenames. Any error opening either file, reading from
    'src', or writing to 'dst', raises DistutilsFileError.  Data is
    read/written in chunks of 'buffer_size' bytes (default 16k).  No attempt
    is made to handle anything apart from regular files.
    """
    # Stolen from shutil module in the standard library, but with
    # custom error-handling added.
    fsrc = None
    fdst = None
    try:
        try:
            fsrc = open(src, 'rb')
        except os.error, (errno, errstr):
            raise DistutilsFileError("could not open '%s': %s" % (src, errstr))

        if os.path.exists(dst):
            try:
                os.unlink(dst)
            except os.error, (errno, errstr):
                raise DistutilsFileError(
                      "could not delete '%s': %s" % (dst, errstr))

        try:
            fdst = open(dst, 'wb')
        except os.error, (errno, errstr):
            raise DistutilsFileError(
                  "could not create '%s': %s" % (dst, errstr))

        while 1:
            try:
                buf = fsrc.read(buffer_size)
            except os.error, (errno, errstr):
                raise DistutilsFileError(
                      "could not read from '%s': %s" % (src, errstr))

            if not buf:
                break

            try:
                fdst.write(buf)
            except os.error, (errno, errstr):
                raise DistutilsFileError(
                      "could not write to '%s': %s" % (dst, errstr))

    finally:
        if fdst:
            fdst.close()
        if fsrc:
            fsrc.close()

def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
              link=None, verbose=1, dry_run=0):
    """Copy a file 'src' to 'dst'.

    If 'dst' is a directory, then 'src' is copied there with the same name;
    otherwise, it must be a filename.  (If the file exists, it will be
    ruthlessly clobbered.)  If 'preserve_mode' is true (the default),
    the file's mode (type and permission bits, or whatever is analogous on
    the current platform) is copied.  If 'preserve_times' is true (the
    default), the last-modified and last-access times are copied as well.
    If 'update' is true, 'src' will only be copied if 'dst' does not exist,
    or if 'dst' does exist but is older than 'src'.

    '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 is
    None (the default), files are copied.  Don't set 'link' on systems that
    don't support it: 'copy_file()' doesn't check if hard or symbolic
    linking is available.

    Under Mac OS, uses the native file copy function in macostools; on
    other systems, uses '_copy_file_contents()' to copy file contents.

    Return a tuple (dest_name, copied): 'dest_name' is the actual name of
    the output file, and 'copied' is true if the file was copied (or would
    have been copied, if 'dry_run' true).
    """
    # XXX if the destination file already exists, we clobber it if
    # copying, but blow up if linking.  Hmmm.  And I don't know what
    # macostools.copyfile() does.  Should definitely be consistent, and
    # should probably blow up if destination exists and we would be
    # changing it (ie. it's not already a hard/soft link to src OR
    # (not update) and (src newer than dst).

    from distutils.dep_util import newer
    from stat import ST_ATIME, ST_MTIME, ST_MODE, S_IMODE

    if not os.path.isfile(src):
        raise DistutilsFileError(
              "can't copy '%s': doesn't exist or not a regular file" % src)

    if os.path.isdir(dst):
        dir = dst
        dst = os.path.join(dst, os.path.basename(src))
    else:
        dir = os.path.dirname(dst)

    if update and not newer(src, dst):
        if verbose >= 1:
            log.debug("not copying %s (output up-to-date)", src)
        return dst, 0

    try:
        action = _copy_action[link]
    except KeyError:
        raise ValueError("invalid value '%s' for 'link' argument" % link)

    if verbose >= 1:
        if os.path.basename(dst) == os.path.basename(src):
            log.info("%s %s -> %s", action, src, dir)
        else:
            log.info("%s %s -> %s", action, src, dst)

    if dry_run:
        return (dst, 1)

    # If linking (hard or symbolic), use the appropriate system call
    # (Unix only, of course, but that's the caller's responsibility)
    if link == 'hard':
        if not (os.path.exists(dst) and os.path.samefile(src, dst)):
            os.link(src, dst)
    elif link == 'sym':
        if not (os.path.exists(dst) and os.path.samefile(src, dst)):
            os.symlink(src, dst)

    # Otherwise (non-Mac, not linking), copy the file contents and
    # (optionally) copy the times and mode.
    else:
        _copy_file_contents(src, dst)
        if preserve_mode or preserve_times:
            st = os.stat(src)

            # According to David Ascher <da@ski.org>, utime() should be done
            # before chmod() (at least under NT).
            if preserve_times:
                os.utime(dst, (st[ST_ATIME], st[ST_MTIME]))
            if preserve_mode:
                os.chmod(dst, S_IMODE(st[ST_MODE]))

    return (dst, 1)

# XXX I suspect this is Unix-specific -- need porting help!
def move_file (src, dst, verbose=1, dry_run=0):
    """Move a file 'src' to 'dst'.

    If 'dst' is a directory, the file will be moved into it with the same
    name; otherwise, 'src' is just renamed to 'dst'.  Return the new
    full name of the file.

    Handles cross-device moves on Unix using 'copy_file()'.  What about
    other systems???
    """
    from os.path import exists, isfile, isdir, basename, dirname
    import errno

    if verbose >= 1:
        log.info("moving %s -> %s", src, dst)

    if dry_run:
        return dst

    if not isfile(src):
        raise DistutilsFileError("can't move '%s': not a regular file" % src)

    if isdir(dst):
        dst = os.path.join(dst, basename(src))
    elif exists(dst):
        raise DistutilsFileError(
              "can't move '%s': destination '%s' already exists" %
              (src, dst))

    if not isdir(dirname(dst)):
        raise DistutilsFileError(
              "can't move '%s': destination '%s' not a valid path" % \
              (src, dst))

    copy_it = 0
    try:
        os.rename(src, dst)
    except os.error, (num, msg):
        if num == errno.EXDEV:
            copy_it = 1
        else:
            raise DistutilsFileError(
                  "couldn't move '%s' to '%s': %s" % (src, dst, msg))

    if copy_it:
        copy_file(src, dst, verbose=verbose)
        try:
            os.unlink(src)
        except os.error, (num, msg):
            try:
                os.unlink(dst)
            except os.error:
                pass
            raise DistutilsFileError(
                  ("couldn't move '%s' to '%s' by copy/delete: " +
                   "delete '%s' failed: %s") %
                  (src, dst, src, msg))
    return dst


def write_file (filename, contents):
    """Create a file with the specified name and write 'contents' (a
    sequence of strings without line terminators) to it.
    """
    f = open(filename, "w")
    try:
        for line in contents:
            f.write(line + "\n")
    finally:
        f.close()
N4m3
5!z3
L45t M0d!f!3d
0wn3r / Gr0up
P3Rm!55!0n5
0pt!0n5
..
--
December 20 2023 04:52:59
0 / 0
0755
command
--
December 20 2023 04:52:59
0 / 0
0755
README
0.288 KB
November 14 2023 16:14:19
0 / 0
0644
__init__.py
0.329 KB
November 14 2023 16:14:19
0 / 0
0644
__init__.pyc
0.376 KB
November 14 2023 16:14:41
0 / 0
0644
__init__.pyo
0.376 KB
November 14 2023 16:14:41
0 / 0
0644
archive_util.py
7.639 KB
November 14 2023 16:14:19
0 / 0
0644
archive_util.pyc
7.281 KB
November 14 2023 16:14:41
0 / 0
0644
archive_util.pyo
7.281 KB
November 14 2023 16:14:41
0 / 0
0644
bcppcompiler.py
14.591 KB
November 14 2023 16:14:19
0 / 0
0644
bcppcompiler.pyc
7.697 KB
November 14 2023 16:14:41
0 / 0
0644
bcppcompiler.pyo
7.697 KB
November 14 2023 16:14:41
0 / 0
0644
ccompiler.py
45.54 KB
November 14 2023 16:14:19
0 / 0
0644
ccompiler.pyc
35.961 KB
November 14 2023 16:14:41
0 / 0
0644
ccompiler.pyo
35.823 KB
November 14 2023 16:14:43
0 / 0
0644
cmd.py
18.818 KB
November 14 2023 16:14:19
0 / 0
0644
cmd.pyc
16.41 KB
November 14 2023 16:14:41
0 / 0
0644
cmd.pyo
16.41 KB
November 14 2023 16:14:41
0 / 0
0644
config.py
4.033 KB
November 14 2023 16:14:19
0 / 0
0644
config.pyc
3.485 KB
November 14 2023 16:14:41
0 / 0
0644
config.pyo
3.485 KB
November 14 2023 16:14:41
0 / 0
0644
core.py
8.88 KB
November 14 2023 16:14:19
0 / 0
0644
core.pyc
7.495 KB
November 14 2023 16:14:41
0 / 0
0644
core.pyo
7.495 KB
November 14 2023 16:14:41
0 / 0
0644
cygwinccompiler.py
16.865 KB
November 14 2023 16:14:19
0 / 0
0644
cygwinccompiler.pyc
9.188 KB
November 14 2023 16:14:41
0 / 0
0644
cygwinccompiler.pyo
9.188 KB
November 14 2023 16:14:41
0 / 0
0644
debug.py
0.158 KB
November 14 2023 16:14:19
0 / 0
0644
debug.pyc
0.248 KB
November 14 2023 16:14:41
0 / 0
0644
debug.pyo
0.248 KB
November 14 2023 16:14:41
0 / 0
0644
dep_util.py
3.427 KB
November 14 2023 16:14:19
0 / 0
0644
dep_util.pyc
3.105 KB
November 14 2023 16:14:41
0 / 0
0644
dep_util.pyo
3.105 KB
November 14 2023 16:14:41
0 / 0
0644
dir_util.py
7.781 KB
November 14 2023 16:14:19
0 / 0
0644
dir_util.pyc
6.718 KB
November 14 2023 16:14:41
0 / 0
0644
dir_util.pyo
6.718 KB
November 14 2023 16:14:41
0 / 0
0644
dist.py
48.876 KB
November 14 2023 16:14:19
0 / 0
0644
dist.pyc
38.644 KB
November 14 2023 16:14:41
0 / 0
0644
dist.pyo
38.644 KB
November 14 2023 16:14:41
0 / 0
0644
emxccompiler.py
11.651 KB
November 14 2023 16:14:19
0 / 0
0644
emxccompiler.pyc
7.292 KB
November 14 2023 16:14:41
0 / 0
0644
emxccompiler.pyo
7.292 KB
November 14 2023 16:14:41
0 / 0
0644
errors.py
3.412 KB
November 14 2023 16:14:19
0 / 0
0644
errors.pyc
6.138 KB
November 14 2023 16:14:41
0 / 0
0644
errors.pyo
6.138 KB
November 14 2023 16:14:41
0 / 0
0644
extension.py
10.648 KB
November 14 2023 16:14:19
0 / 0
0644
extension.pyc
7.237 KB
November 14 2023 16:14:41
0 / 0
0644
extension.pyo
7.017 KB
November 14 2023 16:14:43
0 / 0
0644
fancy_getopt.py
17.527 KB
November 14 2023 16:14:19
0 / 0
0644
fancy_getopt.pyc
11.678 KB
November 14 2023 16:14:41
0 / 0
0644
fancy_getopt.pyo
11.505 KB
November 14 2023 16:14:43
0 / 0
0644
file_util.py
7.612 KB
November 14 2023 16:14:19
0 / 0
0644
file_util.pyc
6.471 KB
November 14 2023 16:14:41
0 / 0
0644
file_util.pyo
6.471 KB
November 14 2023 16:14:41
0 / 0
0644
filelist.py
12.392 KB
November 14 2023 16:14:19
0 / 0
0644
filelist.pyc
10.511 KB
November 14 2023 16:14:41
0 / 0
0644
filelist.pyo
10.511 KB
November 14 2023 16:14:41
0 / 0
0644
log.py
1.646 KB
November 14 2023 16:14:19
0 / 0
0644
log.pyc
2.721 KB
November 14 2023 16:14:41
0 / 0
0644
log.pyo
2.721 KB
November 14 2023 16:14:41
0 / 0
0644
msvc9compiler.py
30.291 KB
November 14 2023 16:14:19
0 / 0
0644
msvc9compiler.pyc
21.035 KB
November 14 2023 16:14:41
0 / 0
0644
msvc9compiler.pyo
20.964 KB
November 14 2023 16:14:43
0 / 0
0644
msvccompiler.py
23.083 KB
November 14 2023 16:14:19
0 / 0
0644
msvccompiler.pyc
17.112 KB
November 14 2023 16:14:41
0 / 0
0644
msvccompiler.pyo
17.112 KB
November 14 2023 16:14:41
0 / 0
0644
spawn.py
7.607 KB
November 14 2023 16:14:19
0 / 0
0644
spawn.pyc
6.022 KB
November 14 2023 16:14:41
0 / 0
0644
spawn.pyo
6.022 KB
November 14 2023 16:14:41
0 / 0
0644
sysconfig.py
16.521 KB
November 14 2023 16:14:24
0 / 0
0644
sysconfig.py.debug-build
16.42 KB
November 14 2023 16:14:19
0 / 0
0644
sysconfig.pyc
12.957 KB
November 14 2023 16:14:41
0 / 0
0644
sysconfig.pyo
12.957 KB
November 14 2023 16:14:41
0 / 0
0644
text_file.py
12.119 KB
November 14 2023 16:14:19
0 / 0
0644
text_file.pyc
9.027 KB
November 14 2023 16:14:41
0 / 0
0644
text_file.pyo
9.027 KB
November 14 2023 16:14:41
0 / 0
0644
unixccompiler.py
12.558 KB
November 14 2023 16:14:19
0 / 0
0644
unixccompiler.py.distutils-rpath
12.025 KB
November 14 2023 16:14:19
0 / 0
0644
unixccompiler.pyc
7.765 KB
November 14 2023 16:14:41
0 / 0
0644
unixccompiler.pyo
7.765 KB
November 14 2023 16:14:41
0 / 0
0644
util.py
18.284 KB
November 14 2023 16:14:19
0 / 0
0644
util.pyc
14.575 KB
November 14 2023 16:14:41
0 / 0
0644
util.pyo
14.575 KB
November 14 2023 16:14:41
0 / 0
0644
version.py
11.165 KB
November 14 2023 16:14:19
0 / 0
0644
version.pyc
7.039 KB
November 14 2023 16:14:41
0 / 0
0644
version.pyo
7.039 KB
November 14 2023 16:14:41
0 / 0
0644
versionpredicate.py
4.976 KB
November 14 2023 16:14:19
0 / 0
0644
versionpredicate.pyc
5.412 KB
November 14 2023 16:14:41
0 / 0
0644
versionpredicate.pyo
5.412 KB
November 14 2023 16:14:41
0 / 0
0644