Esempio n. 1
0
 def copy_file(self, infile, outfile,
                preserve_mode=1, preserve_times=1, link=None, level=1):
     """Copy a file respecting verbose, dry-run and force flags.  (The
     former two default to whatever is in the Distribution object, and
     the latter defaults to false for commands that don't define it.)"""
     if self.dry_run:
         # XXX add a comment
         return
     if os.path.isdir(outfile):
         outfile = os.path.join(outfile, os.path.split(infile)[-1])
     copyfile(infile, outfile)
     return outfile, None  # XXX
Esempio n. 2
0
    def copy_file(self, infile, outfile,
                  preserve_mode=True, preserve_times=True, link=None, level=1):
        """Copy a file respecting dry-run and force flags.

        (dry-run defaults to whatever is in the Distribution object, and
        force to false for commands that don't define it.)
        """
        if self.dry_run:
            # XXX add a comment
            return
        if os.path.isdir(outfile):
            outfile = os.path.join(outfile, os.path.split(infile)[-1])
        copyfile(infile, outfile)
        return outfile, None  # XXX
Esempio n. 3
0
    def test_w_dest_open_fails(self):

        srcfile = self.Faux()

        def _open(filename, mode='r'):
            if filename == 'srcfile':
                return srcfile
            if filename == 'destfile':
                raise IOError('Cannot open "destfile"')
            assert 0  # shouldn't reach here.

        self._set_shutil_open(_open)

        shutil.copyfile('srcfile', 'destfile')
        self.assertTrue(srcfile._entered)
        self.assertTrue(srcfile._exited_with[0] is IOError)
        self.assertEqual(srcfile._exited_with[1].args,
                         ('Cannot open "destfile"', ))
Esempio n. 4
0
    def _test_w_dest_open_fails(self):

        srcfile = self.Faux()

        def _open(filename, mode='r'):
            if filename == 'srcfile':
                return srcfile
            if filename == 'destfile':
                raise IOError('Cannot open "destfile"')
            assert 0  # shouldn't reach here.

        self._set_shutil_open(_open)

        shutil.copyfile('srcfile', 'destfile')
        self.assertTrue(srcfile._entered)
        self.assertTrue(srcfile._exited_with[0] is IOError)
        self.assertEqual(srcfile._exited_with[1].args,
                         ('Cannot open "destfile"',))