Revision: 4435
Author: pekka.klarck
Date: Tue Dec  7 06:32:57 2010
Log: extract method
http://code.google.com/p/robotframework/source/detail?r=4435

Modified:
 /trunk/src/robot/libraries/Screenshot.py

=======================================
--- /trunk/src/robot/libraries/Screenshot.py    Mon May 31 05:21:54 2010
+++ /trunk/src/robot/libraries/Screenshot.py    Tue Dec  7 06:32:57 2010
@@ -80,10 +80,7 @@

The directory holding the file must exist or an exception is raised.
         """
-        path = os.path.abspath(path.replace('/', os.sep))
-        if not os.path.exists(os.path.dirname(path)):
- raise RuntimeError("Directory '%s' where to save the screenshot does "
-                            "not exist" % os.path.dirname(path))
+        path = self._get_save_path(path)
         screensize = Toolkit.getDefaultToolkit().getScreenSize()
         rectangle = Rectangle(0, 0, screensize.width, screensize.height)
         image = Robot().createScreenCapture(rectangle)
@@ -91,6 +88,13 @@
         print "Screenshot saved to '%s'" % path
         return path

+    def _get_save_path(self, path):
+        path = os.path.abspath(path.replace('/', os.sep))
+        if os.path.exists(os.path.dirname(path)):
+            return path
+ raise RuntimeError("Directory '%s' where to save the screenshot does "
+                           "not exist" % os.path.dirname(path))
+
     def save_screenshot(self, basename="screenshot", directory=None):
         """Saves a screenshot with a generated unique name.

Reply via email to