Beispiel #1
0
    def get_match(self, abs_path):
        relative_path = relpath(abs_path, self.dirname)
        if os.name == "nt":
            relative_path = relative_path.replace("\\", "/")
        relative_path = cast_bytes(relative_path, "utf-8")

        for pattern in self.patterns:
            if match_pattern(relative_path,
                             pattern) and self._no_negate_pattern_matches(
                                 relative_path):
                return (abs_path, pattern, self.ignore_file_path)
        return None
 def test_no_matches(self):
     for (path, pattern) in NEGATIVE_MATCH_TESTS:
         self.assertFalse(
             match_pattern(path, pattern),
             "path: %r, pattern: %r" % (path, pattern),
         )
 def test_matches(self):
     for (path, pattern) in POSITIVE_MATCH_TESTS:
         self.assertTrue(
             match_pattern(path, pattern),
             "path: %r, pattern: %r" % (path, pattern),
         )
Beispiel #4
0
 def _no_negate_pattern_matches(self, path):
     return all([not match_pattern(path, p) for p in self.negate_patterns])
Beispiel #5
0
 def test_no_matches(self):
     for (path, pattern) in NEGATIVE_MATCH_TESTS:
         self.assertFalse(
             match_pattern(path, pattern),
             "path: %r, pattern: %r" % (path, pattern))
Beispiel #6
0
 def test_matches(self):
     for (path, pattern) in POSITIVE_MATCH_TESTS:
         self.assertTrue(
             match_pattern(path, pattern),
             "path: %r, pattern: %r" % (path, pattern))