2 new revisions:
Revision: 8894d2062440
Branch: default
Author: Pekka Klärck
Date: Wed Sep 19 04:06:46 2012
Log: little more performance optimization for new lower() method with
ipy
http://code.google.com/p/robotframework/source/detail?r=8894d2062440
Revision: 9b3df1313017
Branch: default
Author: Pekka Klärck
Date: Wed Sep 19 05:30:15 2012
Log: Moved isatty helper from running.monitor to utils because it is
needed...
http://code.google.com/p/robotframework/source/detail?r=9b3df1313017
==============================================================================
Revision: 8894d2062440
Branch: default
Author: Pekka Klärck
Date: Wed Sep 19 04:06:46 2012
Log: little more performance optimization for new lower() method with
ipy
http://code.google.com/p/robotframework/source/detail?r=8894d2062440
Modified:
/src/robot/utils/normalizing.py
/utest/utils/test_normalizing.py
=======================================
--- /src/robot/utils/normalizing.py Wed Sep 19 03:11:15 2012
+++ /src/robot/utils/normalizing.py Wed Sep 19 04:06:46 2012
@@ -47,13 +47,15 @@
def lower(string):
if string.islower():
return string
- if not _has_non_ascii_chars(string):
+ if string.isupper():
+ return string.swapcase()
+ if not _has_uppercase_non_ascii_chars(string):
return string.lower()
return ''.join(c if not c.isupper() else c.swapcase() for c in
string)
- def _has_non_ascii_chars(string):
+ def _has_uppercase_non_ascii_chars(string):
for c in string:
- if c >= u'\x80':
+ if c >= u'\x80' and c.isupper():
return True
return False
=======================================
--- /utest/utils/test_normalizing.py Wed Sep 19 03:11:15 2012
+++ /utest/utils/test_normalizing.py Wed Sep 19 04:06:46 2012
@@ -8,16 +8,17 @@
class TestNormalizing(unittest.TestCase):
def test_normalize_with_defaults(self):
- for inp, exp in [ ('', ''),
- (' ', ''),
- (' \n\t\r', ''),
- ('foo', 'foo'),
- (' f o o ', 'foo'),
- ('_BAR', '_bar'),
- ('Fo OBar\r\n', 'foobar'),
- ('foo\tbar', 'foobar'),
- ('\n \n \n \n F o O \t\tBaR \r \r
\r ', 'foobar') ]:
- assert_equals(exp, normalize(inp))
+ for inp, exp in [('', ''),
+ (' ', ''),
+ (' \n\t\r', ''),
+ ('foo', 'foo'),
+ ('BAR', 'bar'),
+ (' f o o ', 'foo'),
+ ('_BAR', '_bar'),
+ ('Fo OBar\r\n', 'foobar'),
+ ('foo\tbar', 'foobar'),
+ ('\n \n \n \n F o O \t\tBaR \r \r
\r ', 'foobar')]:
+ assert_equals(normalize(inp), exp)
def test_normalize_with_caseless(self):
assert_equals(normalize('Fo o BaR', caseless=False), 'FooBaR')
@@ -25,7 +26,8 @@
def test_normalize_with_caseless_non_ascii(self):
assert_equals(normalize(u'\xc4iti', caseless=False), u'\xc4iti')
- assert_equals(normalize(u'\xc4iti', caseless=True), u'\xe4iti')
+ for mother in [u'\xc4ITI', u'\xc4iTi', u'\xe4iti', u'\xe4iTi']:
+ assert_equals(normalize(mother, caseless=True), u'\xe4iti')
def test_normalize_with_spaceless(self):
assert_equals(normalize('Fo o BaR', spaceless=False), 'fo o bar')
==============================================================================
Revision: 9b3df1313017
Branch: default
Author: Pekka Klärck
Date: Wed Sep 19 05:30:15 2012
Log: Moved isatty helper from running.monitor to utils because it is
needed also elsewhere. Also added code for different isatty implementation
with IronPython.
http://code.google.com/p/robotframework/source/detail?r=9b3df1313017
Modified:
/src/robot/output/monitor.py
/src/robot/utils/__init__.py
/src/robot/utils/misc.py
=======================================
--- /src/robot/output/monitor.py Thu Sep 13 13:48:59 2012
+++ /src/robot/output/monitor.py Wed Sep 19 05:30:15 2012
@@ -167,7 +167,7 @@
for stream in streams)
def _get_highlighter(self, stream, colors):
- auto = Highlighter if isatty(stream) else NoHighlighting
+ auto = Highlighter if utils.isatty(stream) else NoHighlighting
highlighter = {'AUTO': auto,
'ON': Highlighter,
'FORCE': Highlighter, # compatibility with 2.5.5
and earlier
@@ -205,7 +205,7 @@
self.marker_count = 0
def _marking_enabled(self, markers, stdout):
- auto = isatty(stdout)
+ auto = utils.isatty(stdout)
return {'AUTO': auto,
'ON': True,
'OFF': False}.get(markers.upper(), auto)
@@ -219,6 +219,3 @@
def reset_count(self):
self.marker_count = 0
-
-def isatty(stream):
- return hasattr(stream, 'isatty') and stream.isatty()
=======================================
--- /src/robot/utils/__init__.py Wed Sep 19 03:11:15 2012
+++ /src/robot/utils/__init__.py Wed Sep 19 05:30:15 2012
@@ -32,7 +32,7 @@
from .markupwriters import HtmlWriter, XmlWriter, NullMarkupWriter
from .importer import Importer
from .match import eq, matches, matches_any, Matcher, MultiMatcher
-from .misc import plural_or_not, printable_name, seq2str, seq2str2, getdoc
+from .misc import plural_or_not, printable_name, seq2str, seq2str2,
getdoc, isatty
from .normalizing import lower, normalize, normalize_tags, NormalizedDict
from .robotenv import get_env_var, set_env_var, del_env_var, get_env_vars
from .robotpath import normpath, abspath, get_link_path
=======================================
--- /src/robot/utils/misc.py Thu Jun 7 07:22:47 2012
+++ /src/robot/utils/misc.py Wed Sep 19 05:30:15 2012
@@ -13,6 +13,7 @@
# limitations under the License.
import inspect
+import sys
from .unic import unic
@@ -102,3 +103,15 @@
return doc.decode('UTF-8')
except UnicodeDecodeError:
return unic(doc)
+
+
+# On IronPython sys.stdxxx.isatty() always returns True
+if sys.platform != 'cli':
+
+ def isatty(stream):
+ return hasattr(stream, 'isatty') and stream.isatty()
+
+else:
+
+ def isatty(stream):
+ return True