357 |
357 |
358 `pattern` can't end with a wildcard component, since that would |
358 `pattern` can't end with a wildcard component, since that would |
359 match an entire tree, and not just its root. |
359 match an entire tree, and not just its root. |
360 |
360 |
361 """ |
361 """ |
|
362 pattern_sep = sep(pattern) |
|
363 |
362 if len(pattern) > 1: |
364 if len(pattern) > 1: |
363 pattern = pattern.rstrip(r"\/") |
365 pattern = pattern.rstrip(r"\/") |
364 |
366 |
365 # The pattern can't end with a wildcard component. |
367 # The pattern can't end with a wildcard component. |
366 if pattern.endswith("*"): |
368 if pattern.endswith("*"): |
367 raise CoverageException("Pattern must not end with wildcards.") |
369 raise CoverageException("Pattern must not end with wildcards.") |
368 pattern_sep = sep(pattern) |
|
369 |
370 |
370 # The pattern is meant to match a filepath. Let's make it absolute |
371 # The pattern is meant to match a filepath. Let's make it absolute |
371 # unless it already is, or is meant to match any prefix. |
372 # unless it already is, or is meant to match any prefix. |
372 if not pattern.startswith('*') and not isabs_anywhere(pattern): |
373 if not pattern.startswith('*') and not isabs_anywhere(pattern + |
|
374 pattern_sep): |
373 pattern = abs_file(pattern) |
375 pattern = abs_file(pattern) |
374 if not pattern.endswith(pattern_sep): |
376 if not pattern.endswith(pattern_sep): |
375 pattern += pattern_sep |
377 pattern += pattern_sep |
376 |
378 |
377 # Make a regex from the pattern. |
379 # Make a regex from the pattern. |