4 new revisions:

Revision: 096d844b129d
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:02:02 2013 UTC
Log:      oops, utests missing from earlier commit
http://code.google.com/p/robotframework/source/detail?r=096d844b129d

Revision: 7970b99a4b3e
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:05:04 2013 UTC
Log:      Small cleanup to Copy/Move File logic....
http://code.google.com/p/robotframework/source/detail?r=7970b99a4b3e

Revision: cb9bccb9087b
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:38:04 2013 UTC
Log:      Cleanup.
http://code.google.com/p/robotframework/source/detail?r=cb9bccb9087b

Revision: 6c1308ccc136
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:41:35 2013 UTC
Log:      Disallowed using dict in place of kwargs except with Java....
http://code.google.com/p/robotframework/source/detail?r=6c1308ccc136

==============================================================================
Revision: 096d844b129d
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:02:02 2013 UTC
Log:      oops, utests missing from earlier commit
http://code.google.com/p/robotframework/source/detail?r=096d844b129d

Modified:
 /utest/utils/test_islike.py

=======================================
--- /utest/utils/test_islike.py Fri Nov 29 14:08:56 2013 UTC
+++ /utest/utils/test_islike.py Mon Dec  2 22:02:02 2013 UTC
@@ -1,4 +1,5 @@
 import unittest
+import sys

 try:
     from collections import Mapping
@@ -66,6 +67,16 @@
         for thing in ['', u'', 1, None, True, object(), [], (), set()]:
             assert_equals(is_dict_like(thing), False, thing)

+    def test_java(self):
+        if sys.platform.startswith('java'):
+            from java.util import HashMap
+            assert_equals(is_dict_like(HashMap()), False)
+            assert_equals(is_dict_like(HashMap(), allow_java=True), True)
+            assert_equals(is_dict_like([], allow_java=True), False)
+        else:
+            assert_equals(is_dict_like({}, allow_java=True), True)
+            assert_equals(is_dict_like([], allow_java=True), False)
+

 class TestStringlike(unittest.TestCase):


==============================================================================
Revision: 7970b99a4b3e
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:05:04 2013 UTC
Log:      Small cleanup to Copy/Move File logic.

Update issue 1600
Small cleanup. Mainly shortened destination -> dest in variable and helper function names to make lines shorter and easier to read.

Tests pass on Linux and Windows using Python/Jython/IronPython. I think this is pretty much done but leave it for Mikko to decide.
http://code.google.com/p/robotframework/source/detail?r=7970b99a4b3e

Modified:
 /src/robot/libraries/OperatingSystem.py

=======================================
--- /src/robot/libraries/OperatingSystem.py     Mon Dec  2 13:27:48 2013 UTC
+++ /src/robot/libraries/OperatingSystem.py     Mon Dec  2 22:05:04 2013 UTC
@@ -744,27 +744,28 @@

         Arguments have exactly same semantics as with `Copy File` keyword.
         """
- source, destination, _ = self._prepare_for_move_or_copy(destination, source) + source, destination, _ = self._prepare_for_move_or_copy(source, destination)
         shutil.move(source, destination)
         self._link("Moved file from '%s' to '%s'", source, destination)

-    def _prepare_for_move_or_copy(self, destination, source):
- source, destination, dest_is_dir = self._normalize_dest_and_source(destination, source)
+    def _prepare_for_move_or_copy(self, source, dest):
+ source, dest, dest_is_dir = self._normalize_source_and_dest(source, dest)
         self._verify_that_source_is_a_file(source)
-        parent = self._ensure_directory_exists(destination, dest_is_dir)
- self._ensure_destination_file_does_not_exist(destination, dest_is_dir, source)
-        return source, destination, parent
+        parent = self._ensure_directory_exists(dest, dest_is_dir)
+        self._ensure_dest_file_does_not_exist(source, dest, dest_is_dir)
+        return source, dest, parent

- def _ensure_destination_file_does_not_exist(self, destination, dest_is_dir, source): - dest = os.path.join(destination, os.path.basename(source)) if dest_is_dir else destination
+    def _ensure_dest_file_does_not_exist(self, source, dest, dest_is_dir):
+        if dest_is_dir:
+            dest = os.path.join(dest, os.path.basename(source))
         if os.path.isfile(dest):
             os.remove(dest)

-    def _copy_file(self, source, destination):
- source, destination, parent = self._prepare_for_move_or_copy(destination, source)
-        return self._atomic_copy(source, destination, parent)
+    def _copy_file(self, source, dest):
+        source, dest, parent = self._prepare_for_move_or_copy(source, dest)
+        return self._atomic_copy(source, dest, parent)

-    def _normalize_dest_and_source(self, dest, source):
+    def _normalize_source_and_dest(self, source, dest):
         source = self._absnorm(source)
         dest = dest.replace('/', os.sep)
         dest_is_dir = dest.endswith(os.sep) or os.path.isdir(dest)
@@ -777,9 +778,9 @@
         if not os.path.isfile(source):
raise RuntimeError("Source file '%s' is not a regular file" % source)

-    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):
+    def _ensure_directory_exists(self, dest, dest_is_dir):
+        parent = dest if dest_is_dir else os.path.dirname(dest)
+        if not os.path.exists(dest) and not os.path.exists(parent):
             os.makedirs(parent)
         return parent

@@ -799,11 +800,6 @@
         os.rmdir(temp_directory)
         return source, destination

-    def _destination_directory(self, destination, dest_is_dir):
-        if dest_is_dir:
-            return destination
-        return os.path.dirname(destination)
-
     def copy_directory(self, source, destination):
         """Copies the source directory into the destination.


==============================================================================
Revision: cb9bccb9087b
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:38:04 2013 UTC
Log:      Cleanup.
http://code.google.com/p/robotframework/source/detail?r=cb9bccb9087b

Modified:
 /src/robot/running/arguments/javaargumentcoercer.py
 /src/robot/running/handlers.py

=======================================
--- /src/robot/running/arguments/javaargumentcoercer.py Fri Nov 29 12:25:23 2013 UTC +++ /src/robot/running/arguments/javaargumentcoercer.py Mon Dec 2 22:38:04 2013 UTC
@@ -15,6 +15,7 @@
 from java.lang import Byte, Short, Integer, Long, Boolean, Float, Double

 from robot.variables import contains_var
+from robot.utils import is_list_like


 class JavaArgumentCoercer(object):
@@ -138,15 +139,7 @@
         return arguments

     def _passing_list(self, arguments):
- return self._correct_count(arguments) and self._is_list(arguments[-1]) + return self._correct_count(arguments) and is_list_like(arguments[-1])

     def _correct_count(self, arguments):
         return len(arguments) == self._index + 1
-
-    def _is_list(self, argument):
-        try:
-            list(argument)
-        except TypeError:
-            return False
-        else:
-            return not isinstance(argument, basestring)
=======================================
--- /src/robot/running/handlers.py      Mon Dec  2 21:31:37 2013 UTC
+++ /src/robot/running/handlers.py      Mon Dec  2 22:38:04 2013 UTC
@@ -186,8 +186,8 @@

     def resolve_arguments(self, args, variables=None):
positional, named = self._argument_resolver.resolve(args, variables)
-        arguments = self._arg_coercer.coerce(
-          positional, named, dryrun=not variables)
+        arguments = self._arg_coercer.coerce(positional, named,
+                                             dryrun=not variables)
         return arguments, {}



==============================================================================
Revision: 6c1308ccc136
Branch:   default
Author:   Pekka Klärck
Date:     Mon Dec  2 22:41:35 2013 UTC
Log:      Disallowed using dict in place of kwargs except with Java.

Update issue 1583
Summary: `**kwargs` support for static Java test libraries
We enabled passing a real Map to a Java keyword accepting Map as the last argument earlier. It also enabled using dicts in place of kwargs elsewhere, but now that is disabled.
http://code.google.com/p/robotframework/source/detail?r=6c1308ccc136

Modified:
 /src/robot/running/arguments/argumentresolver.py
 /src/robot/running/handlers.py

=======================================
--- /src/robot/running/arguments/argumentresolver.py Mon Dec 2 21:31:37 2013 UTC +++ /src/robot/running/arguments/argumentresolver.py Mon Dec 2 22:41:35 2013 UTC
@@ -21,18 +21,18 @@
 class ArgumentResolver(object):

     def __init__(self, argspec, resolve_named=True,
-                 resolve_variables_until=None):
+                 resolve_variables_until=None, dict_to_kwargs=False):
         self._named_resolver = NamedArgumentResolver(argspec) \
             if resolve_named else NullNamedArgumentResolver()
         self._variable_replacer = VariableReplacer(resolve_variables_until)
-        self._kwargs_handler = KwArgsHandler(argspec)
+        self._dict_to_kwargs = DictToKwargs(argspec, dict_to_kwargs)
         self._argument_validator = ArgumentValidator(argspec)

     def resolve(self, arguments, variables=None):
         positional, named = self._named_resolver.resolve(arguments)
positional, named = self._variable_replacer.replace(positional, named,
                                                             variables)
-        positional, name = self._kwargs_handler.handle(positional, named)
+        positional, named = self._dict_to_kwargs.handle(positional, named)
         self._argument_validator.validate(positional, named,
                                           dryrun=not variables)
         return positional, named
@@ -98,21 +98,19 @@
         return arguments, {}


-class KwArgsHandler(object):
+class DictToKwargs(object):

-    def __init__(self, argspec):
+    def __init__(self, argspec, enabled=False):
         self._maxargs = argspec.maxargs
-        self._supports_kwargs = bool(argspec.kwargs)
+        self._enabled = enabled and bool(argspec.kwargs)

     def handle(self, positional, named):
-        if self._extra_arg_has_kwargs(positional, named):
+        if self._enabled and self._extra_arg_has_kwargs(positional, named):
             named = positional.pop()
         return positional, named

     def _extra_arg_has_kwargs(self, positional, named):
-        if named or not self._supports_kwargs:
-            return False
-        if len(positional) != self._maxargs + 1:
+        if named or len(positional) != self._maxargs + 1:
             return False
         return is_dict_like(positional[-1], allow_java=True)

=======================================
--- /src/robot/running/handlers.py      Mon Dec  2 22:38:04 2013 UTC
+++ /src/robot/running/handlers.py      Mon Dec  2 22:41:35 2013 UTC
@@ -176,6 +176,9 @@
         signatures = self._get_signatures(handler_method)
         self._arg_coercer = JavaArgumentCoercer(signatures, self.arguments)

+    def _get_argument_resolver(self, argspec):
+        return ArgumentResolver(argspec, dict_to_kwargs=True)
+
     def _parse_arguments(self, handler_method):
         signatures = self._get_signatures(handler_method)
         return JavaArgumentParser().parse(signatures, self.longname)

--

--- 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 robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to