Revision: 3569
Author: KariHusa
Date: Thu May 27 02:33:42 2010
Log: Clean-up, issue 122
http://code.google.com/p/robotframework/source/detail?r=3569

Modified:
 /trunk/src/robot/libraries/Telnet.py
 /trunk/src/robot/running/arguments.py
 /trunk/src/robot/running/runkwregister.py

=======================================
--- /trunk/src/robot/libraries/Telnet.py        Tue Mar 23 04:15:41 2010
+++ /trunk/src/robot/libraries/Telnet.py        Thu May 27 02:33:42 2010
@@ -16,7 +16,7 @@
 import telnetlib
 import time
 import re
-from types import MethodType, StringTypes
+import inspect

 from robot import utils

@@ -70,7 +70,7 @@
         if self._lib_kws is None:
             self._lib_kws = [ name for name in dir(self)
if not name.startswith('_') and name != 'get_keyword_names'
-                              and type(getattr(self,name)) is MethodType ]
+                              and inspect.ismethod(getattr(self, name)) ]
         return self._lib_kws

     def _get_connection_keywords(self):
@@ -80,7 +80,7 @@
                          if name not in ['write', 'read', 'read_until'] ]
             self._conn_kws = [ name for name in dir(conn)
if not name.startswith('_') and name not in excluded
-                               and type(getattr(conn,name)) is MethodType ]
+                               and inspect.ismethod(getattr(conn, name)) ]
         return self._conn_kws

     def __getattr__(self, name):
@@ -414,7 +414,7 @@
         ret = ret.decode('ASCII', 'ignore')
         self._log(ret, loglevel)
         if index == -1:
-            expected = [ type(exp) in StringTypes and exp or exp.pattern
+ expected = [ exp if isinstance(exp, basestring) else exp.pattern
                          for exp in expected ]
             raise AssertionError("No match found for %s in %s"
% (utils.seq2str(expected, lastsep=' or '),
@@ -503,7 +503,7 @@
     def _is_valid_log_level(self, level, raise_if_invalid=False):
         if level is None:
             return True
-        if type(level) in StringTypes and \
+        if isinstance(level, basestring) and \
                 level.upper() in ['TRACE', 'DEBUG', 'INFO', 'WARN']:
             return True
         if not raise_if_invalid:
=======================================
--- /trunk/src/robot/running/arguments.py       Fri May 21 04:55:54 2010
+++ /trunk/src/robot/running/arguments.py       Thu May 27 02:33:42 2010
@@ -13,7 +13,7 @@
 #  limitations under the License.

 import sys
-from types import MethodType, FunctionType
+import inspect

 from robot.errors import DataError, FrameworkError
 from robot.variables import is_list_var, is_scalar_var
@@ -76,10 +76,10 @@
         """
         # Code below is based on inspect module's getargs and getargspec
         # methods. See their documentation and/or source for more details.
-        if type(handler) is MethodType:
+        if inspect.ismethod(handler):
             func = handler.im_func
             first_arg = 1        # this drops 'self' from methods' args
-        elif type(handler) is FunctionType:
+        elif inspect.isfunction(handler):
             func = handler
             first_arg = 0
         else:
=======================================
--- /trunk/src/robot/running/runkwregister.py   Fri Apr  9 04:42:10 2010
+++ /trunk/src/robot/running/runkwregister.py   Thu May 27 02:33:42 2010
@@ -13,7 +13,7 @@
 #  limitations under the License.


-from types import MethodType, FunctionType
+import inspect

 from robot import utils

@@ -40,9 +40,9 @@
         return self.get_args_to_process(libname, kwname) >= 0

     def _get_args_from_method(self, method):
-        if type(method) is MethodType:
+        if inspect.ismethod(method):
             return method.im_func.func_code.co_argcount -1
-        elif type(method) is FunctionType:
+        elif inspect.isfunction(method):
             return method.func_code.co_argcount
         raise ValueError("Needs function or method!")

Reply via email to