From f4a256b457d7245fa357d3af20ea8f058de32200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Wed, 11 Aug 2010 02:02:18 -0300 Subject: [PATCH] fixes --- couleur.py | 6 +++--- test_file_filter.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/couleur.py b/couleur.py index cc23534..90df1f4 100644 --- a/couleur.py +++ b/couleur.py @@ -57,9 +57,9 @@ def ignore_colors(string): up_count_regex = re.compile(ur'[#][{]up[}]') up_count = len(up_count_regex.findall(string)) or 1 - expression = u'([#][{]up[}])+.*(?P\\n.*){%d}' % up_count - up_supress_regex = re.compile(expression, re.DOTALL) - string = up_supress_regex.sub('\g', string) + expression = u'^([#][{]up[}])+(?P.*\\n){%d}' % up_count + up_supress_regex = re.compile(expression, re.MULTILINE) + string = up_supress_regex.sub('', string) for attr in re.findall("[#][{]on[:](\w+)[}]", string): string = string.replace("#{on:%s}" % attr, "") diff --git a/test_file_filter.py b/test_file_filter.py index be64d03..a041cb3 100644 --- a/test_file_filter.py +++ b/test_file_filter.py @@ -109,8 +109,8 @@ def test_supress_up_when_ignoring_colors(): io = StringIO() couleur.proxy(io).enable() couleur.proxy(io).ignore() - io.write("This is visible#{up}but this is invisible\n") - assert_equals('This is visible\n', io.getvalue()) + io.write("#{up}but this is invisible\n") + assert_equals('', io.getvalue()) def test_supress_up_when_ignoring_colors_as_many_times_needed(): "file-like filter output: supress #{up} as many times as needed" @@ -118,9 +118,9 @@ def test_supress_up_when_ignoring_colors_as_many_times_needed(): io = StringIO() couleur.proxy(io).enable() couleur.proxy(io).ignore() - io.write("This is visible#{up}#{up}#{up}#{up}\n" \ + io.write("#{up}#{up}#{up}#{up}\n" \ " Line one supressed\n" \ " Line two supressed\n" \ " Line three supressed\n") - assert_equals('This is visible\n', io.getvalue()) + assert_equals('', io.getvalue())