Revision: 145
Author:   janne.t.harkonen
Date:     Wed Aug 22 21:55:38 2012
Log:      Separate class for deprecated keywords
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=145

Modified:
 /trunk/src/SSHLibrary/__init__.py

=======================================
--- /trunk/src/SSHLibrary/__init__.py   Thu Aug 16 04:17:12 2012
+++ /trunk/src/SSHLibrary/__init__.py   Wed Aug 22 21:55:38 2012
@@ -31,7 +31,37 @@
 __version__ = VERSION


-class SSHLibrary:
+
+
+class DeprecatedKeywords(object):
+    """Mixin class containing deprecated keywords"""
+
+    def set_timeout(self, timeout):
+        """*DEPRECATED* Use `Set Default Configuration` instead."""
+        old = self._config.timeout
+        self._config.update(timeout=timeout)
+        return utils.secs_to_timestr(old)
+
+    def set_newline(self, newline):
+        """*DEPRECATED* Use `Set Default Configuration` instead."""
+        old = self._config.newline
+        self._config.update(newline=newline)
+        return old
+
+    def set_prompt(self, prompt):
+        """*DEPRECATED* Use `Set Default Configuration` instead."""
+        old = self._config.prompt or ''
+        self._config.update(prompt=prompt)
+        return old
+
+    def set_default_log_level(self, level):
+        """*DEPRECATED* Use `Set Default Configuration` instead."""
+        old = self._config.loglevel
+        self._config.update(loglevel=level)
+        return old
+
+
+class SSHLibrary(DeprecatedKeywords):
     """SSH Library is a test library for Robot Framework that enables
     executing commands and transferring files over an SSH connection.

@@ -193,81 +223,6 @@
         """
         self._client.close()

-    def set_timeout(self, timeout):
-        """Sets the timeout used in read operations to given value.
-
-        `timeout` is given in Robot Framework's time format
-        (e.g. 1 minute 20 seconds).
-
-        The read operations of keywords `Read Until`, `Read Until Prompt`,
- `Read Until Regexp` and `Write Until Expected Output` will try to read - the output until either the expected text appears in the output or the
-        timeout expires. For commands that take long time to produce their
-        output, this timeout must be set properly.
-
-        Old timeout is returned and it can be used to restore it later.
-
-        Example:
-        | ${tout} = | Set Timeout | 2 minute 30 seconds |
-        | Do Something |
-        | Set Timeout | ${tout} |
-        """
-        old = hasattr(self, '_timeout') and self._timeout or None
-        self._timeout = utils.timestr_to_secs(timeout)
-        return old is not None and utils.secs_to_timestr(old) or None
-
-    def set_newline(self, newline):
-        """Sets the newline used by `Write` keyword.
-
-        Old newline is returned and it can be used to restore it later.
-        See `Set Timeout` for an example.
-        """
-        old = self._newline
-        self._newline = self._parse_newline(newline)
-        return old
-
-    def _parse_newline(self, newline):
-        return newline.upper().replace('LF','\n').replace('CR','\r')
-
-    def set_prompt(self, prompt):
-        """Sets the prompt used by the current connection.
-
-        Returns the previous prompt.
-
-        The behavior of this keyword was changed in version 1.1, see also
-        `Set Default Prompt`.
-
-        Example:
-        | ${old_prompt}= | Set Prompt | $ |
-        | Do Something |
-        | Set Prompt | ${old_prompt} |
-        """
-        old = self._client.prompt or ''
-        self._client.prompt = prompt
-        return old
-
-    def set_default_prompt(self, prompt):
-        """Sets the default prompt used by new connections.
-
-        Returns the previous default prompt.
-
-        This keyword was added in version 1.1.
-        """
-        old, self._default_prompt = self._default_prompt, prompt
-        return old
-
-    def set_default_log_level(self, level):
-        """Sets the default log level used by all read keywords.
-
-        The possible values are TRACE, DEBUG, INFO and WARN. The default is
- INFO. The old value is returned and can be used to restore it later,
-        similarly as with `Set Timeout`.
-        """
-        self._is_valid_log_level(level, raise_if_invalid=True)
-        old = self._default_log_level
-        self._default_log_level = level.upper()
-        return old
-
     def login(self, username, password):
         """Logs in to SSH server with given user information.

Reply via email to