Revision: a7678cc62a4d
Branch: default
Author: Mikko Korpela <[email protected]>
Date: Tue Nov 12 10:43:17 2013 UTC
Log: OperatingSystem#move_file use shutil.move instead of _copy_file
http://code.google.com/p/robotframework/source/detail?r=a7678cc62a4d
Modified:
/src/robot/libraries/OperatingSystem.py
=======================================
--- /src/robot/libraries/OperatingSystem.py Fri Nov 8 13:25:05 2013 UTC
+++ /src/robot/libraries/OperatingSystem.py Tue Nov 12 10:43:17 2013 UTC
@@ -746,24 +746,36 @@
Uses `Copy File` keyword internally, and `source` and `destination`
arguments have exactly same semantics as with that keyword.
"""
- source, destination = self._copy_file(source, destination)
- os.remove(source)
+ destination, source, dest_is_dir =
self._normalize_dest_and_source(destination, source)
+ self._verify_that_source_is_a_file(source)
+ self._ensure_directory_exists(destination, dest_is_dir)
+ shutil.move(source, destination)
self._link("Moved file from '%s' to '%s'", source, destination)
def _copy_file(self, source, dest):
+ dest, source, dest_is_dir = self._normalize_dest_and_source(dest,
source)
+ self._verify_that_source_is_a_file(source)
+ parent = self._ensure_directory_exists(dest, dest_is_dir)
+ return self._atomic_copy(source, dest, parent)
+
+ def _normalize_dest_and_source(self, dest, source):
source = self._absnorm(source)
dest = dest.replace('/', os.sep)
dest_is_dir = dest.endswith(os.sep)
dest = self._absnorm(dest)
+ return dest, source, dest_is_dir
+
+ def _verify_that_source_is_a_file(self, source):
if not os.path.exists(source):
raise RuntimeError("Source file '%s' does not exist" % source)
if not os.path.isfile(source):
raise RuntimeError("Source file '%s' is not a regular file" %
source)
- parent = self._destination_directory(dest, dest_is_dir)
- if not os.path.exists(dest):
- if not os.path.exists(parent):
- os.makedirs(parent)
- return self._atomic_copy(source, dest, parent)
+
+ def _ensure_directory_exists(self, path, dest_is_dir):
+ parent = self._destination_directory(path, dest_is_dir)
+ if not os.path.exists(path) and not os.path.exists(parent):
+ os.makedirs(parent)
+ return parent
def _atomic_copy(self, source, destination, destination_parent):
# This method tries to ensure that a file copy operation will not
fail if the destination file is removed during
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.