コード例 #1
0
 def main(self):
     # TODO: write unit test
     location = self.args[1]
     pattern = self.args[2]
     if self.check_attribute(location,
                             AttributeType.PATH) == AttributeType.FOLDER:
         if len(self.args) >= 4:
             print(
                 self._print_results(
                     Regex.match_files(location, pattern, self.args[3])))
         else:
             print(self._print_results(Regex.match_files(location,
                                                         pattern)))
     else:
         print(Regex.match_file(location, pattern))
コード例 #2
0
 def test_replace_files(self):
     Regex.replace_files('TestResources', "[is]{2}\s*\w+", "is geen")
     self.assertTrue(
         Regex.match_file('TestResources\\RegexMatchTest.txt', "is geen"))
     Regex.replace_files("TestResources", "[is]{2}\s*\w+", "is een")
     self.assertTrue(
         Regex.match_file('TestResources\\RegexMatchTest.txt', "is een"))
コード例 #3
0
 def test_match_string(self):
     self.assertTrue(Regex.match_string("dit is een tekst",
                                        "[is]{2}\s*\w+"))
     self.assertFalse(
         Regex.match_string("dit is een tekst", "^[is]{2}\s*\w+$"))
コード例 #4
0
 def test_replace_files_with_filter(self):
     Regex.replace_files('TestResources', "[is]{2}\s*\w+", "is geen",
                         "cant_match_anything")
     self.assertFalse(
         Regex.match_file('TestResources\\RegexMatchTest.txt', "is geen"))
コード例 #5
0
 def test_replace_string(self):
     self.assertEqual(
         Regex.replace_string("dit is een tekst", "[is]{2}\s*\w+",
                              "is geen"), "dit is geen tekst")
コード例 #6
0
 def test_match_files(self):
     self.assertEqual(Regex.match_files("TestResources", "[is]{2}\s*\w+"),
                      ['TestResources\\RegexMatchTest.txt'])
コード例 #7
0
 def test_match_file(self):
     self.assertTrue(Regex.match_file("TestRegex.py", "[is]{2}\s*\w+"))
     self.assertFalse(Regex.match_file("TestRegex.py", "^[is]{2}\s*\w+$"))