|
20 | 20 | # ScanCode.io is a free software code scanning tool from nexB Inc. and others. |
21 | 21 | # Visit https://github.com/aboutcode-org/scancode.io for support and download. |
22 | 22 |
|
| 23 | +import re |
23 | 24 | from collections import Counter |
24 | 25 | from collections import defaultdict |
25 | 26 | from contextlib import suppress |
@@ -1623,21 +1624,20 @@ def match_purldb_resources_post_process(project, logger=None): |
1623 | 1624 | map_count = 0 |
1624 | 1625 |
|
1625 | 1626 | for directory in progress.iter(resource_iterator): |
1626 | | - map_count += _match_purldb_resources_post_process( |
1627 | | - directory, to_extract_directories, to_resources |
1628 | | - ) |
| 1627 | + map_count += _match_purldb_resources_post_process(directory, to_resources) |
1629 | 1628 |
|
1630 | 1629 | logger(f"{map_count:,d} resource processed") |
1631 | 1630 |
|
1632 | 1631 |
|
1633 | | -def _match_purldb_resources_post_process( |
1634 | | - directory_path, to_extract_directories, to_resources |
1635 | | -): |
| 1632 | +def _match_purldb_resources_post_process(directory, to_resources): |
| 1633 | + # Escape special character in directory path |
| 1634 | + escaped_directory_path = re.escape(directory.path) |
| 1635 | + |
1636 | 1636 | # Exclude the content of nested archive. |
1637 | 1637 | interesting_codebase_resources = ( |
1638 | | - to_resources.filter(path__startswith=directory_path) |
| 1638 | + to_resources.filter(path__startswith=directory.path) |
1639 | 1639 | .filter(status=flag.MATCHED_TO_PURLDB_RESOURCE) |
1640 | | - .exclude(path__regex=rf"^{directory_path}.*-extract\/.*$") |
| 1640 | + .exclude(path__regex=rf"^{escaped_directory_path}.*-extract\/.*$") |
1641 | 1641 | ) |
1642 | 1642 |
|
1643 | 1643 | if not interesting_codebase_resources: |
|
0 commit comments