From 950ed8fde966ff3de1304be35a43e8398ba5e23b Mon Sep 17 00:00:00 2001 From: sohyeonhwang Date: Thu, 12 Dec 2019 07:47:07 -0600 Subject: [PATCH 1/1] regex scanner groups findall tuple bug fixed --- test/Wikiq_Unit_Test.py | 3 ++- wikiq | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/Wikiq_Unit_Test.py b/test/Wikiq_Unit_Test.py index cc27fb5..7f64a81 100644 --- a/test/Wikiq_Unit_Test.py +++ b/test/Wikiq_Unit_Test.py @@ -320,7 +320,8 @@ class Test_Regex(unittest.TestCase): # sample inputs for checking the outcomes of good inputs / test_basic_regex self.good_inputs_list = [ "-RP '\\b\\d{3}\\b' -RPl threedigits", - "-RP 'TestCase' -RP 'page' -RPl testcases -RPl page_word", + #"-RP 'TestCase' -RP 'page' -RPl testcases -RPl page_word", + "-RP '(\\b[a-zA-Z]{3}\\b)' -RPl 3LETTERS -RP '(\\b(1[\d+])|(2[\d+])\\b)' -RPl NUMBERS", "-CP 'Chevalier' -CPl chev_com -RP 'welcome to Wikipedia' -RPl wiki_welcome -CP 'Warning' -CPl warning", "-CP 'WP:EVADE' -CPl wp_evade" ] diff --git a/wikiq b/wikiq index 0dad9e3..f15eee6 100755 --- a/wikiq +++ b/wikiq @@ -189,7 +189,17 @@ class RegexPair(object): #given that there are matches to be made if self.pattern.search(content) is not None: m = self.pattern.findall(content) - temp_dict[self.label] = ', '.join(m) + m_fixed = [] + for match in m: + if type(match) is tuple: + matchies = set() + for sub_m in match: + matchies.add(sub_m) + m_fixed += matchies + else: + m_fixed.append(match) + + temp_dict[self.label] = ', '.join(m_fixed) else: temp_dict[self.label] = None -- 2.39.5