Skip to content

Commit 05f7981

Browse files
committed
Ensure license index is buildable with extras
Somehow building the index for all languages was failing. This is fixing this issue. Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 7d5199a commit 05f7981

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/licensedcode/cache.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,12 @@ def build_index(
240240
if not licenses_db:
241241
# combine the licenses in these additional directories with the licenses in the original DB
242242
additional_license_dirs = get_license_dirs(additional_dirs=additional_directories)
243-
combined_license_directories = [licenses_data_dir] + additional_license_dirs
244243
# generate a single combined license db with all licenses
245-
licenses_db = load_licenses_from_multiple_dirs(license_dirs=combined_license_directories)
244+
licenses_db = load_licenses_from_multiple_dirs(
245+
builtin_license_data_dir=licenses_data_dir,
246+
additional_license_data_dirs=additional_license_dirs,
247+
with_deprecated=False,
248+
)
246249

247250
# if we have additional directories, extract the rules from them
248251
additional_rule_dirs = get_rule_dirs(additional_dirs=additional_directories)

src/licensedcode/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from licensedcode.frontmatter import dumps_frontmatter
3939
from licensedcode.frontmatter import load_frontmatter
4040
from licensedcode.languages import LANG_INFO as known_languages
41+
from licensedcode.tokenize import get_existing_required_phrase_spans
4142
from licensedcode.tokenize import index_tokenizer
4243
from licensedcode.tokenize import index_tokenizer_with_stopwords
4344
from licensedcode.tokenize import query_lines
@@ -890,6 +891,7 @@ def get_license_dirs(additional_dirs):
890891
Return a list of all subdirectories containing license files within the
891892
input list of additional directories. These directories do not have to be absolute paths.
892893
"""
894+
additional_dirs = additional_dirs or []
893895
return [f"{str(Path(path).absolute())}/licenses" for path in additional_dirs]
894896

895897

@@ -898,6 +900,7 @@ def get_rule_dirs(additional_dirs):
898900
Return a list of all subdirectories containing rule files within the
899901
input list of additional directories. These directories do not have to be absolute paths.
900902
"""
903+
additional_dirs = additional_dirs or []
901904
return [f"{str(Path(path).absolute())}/rules" for path in additional_dirs]
902905

903906

@@ -2295,7 +2298,6 @@ def build_required_phrase_spans(self):
22952298
Return a list of Spans marking required phrases token positions of that must
22962299
be present for this rule to be matched.
22972300
"""
2298-
from licensedcode.required_phrases import get_existing_required_phrase_spans
22992301
if self.is_from_license:
23002302
return []
23012303
try:

0 commit comments

Comments
 (0)