Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/attributecode/attrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,15 @@ def generate_sctk_input(abouts, min_license_score, license_dict):
for key in lic_key:
lic_name.append(license_dict[key][0])
lic_score = about.license_score.value
assert len(lic_key) == len(lic_name)
assert len(lic_key) == len(lic_score)

len_lic_key = len(lic_key)
if len_lic_key != len(lic_name):
raise ValueError(
f"Mismatch between lengths: lic_key ({len_lic_key}) vs lic_name ({len(lic_name)})"
)
if len_lic_key != len(lic_score):
raise ValueError(
f"Mismatch between lengths: lic_key ({len_lic_key}) vs lic_score ({len(lic_score)})"
)
lic_key_expression = about.license_key_expression.value
if lic_key_expression:
updated_lic_key_expression = []
Expand Down
11 changes: 7 additions & 4 deletions src/attributecode/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ def get_locations(location):
"""
location = add_unc(location)
location = get_absolute(location)
assert os.path.exists(location)
if not os.path.exists(location):
raise FileNotFoundError(f"Expected path does not exist: {location}")


if os.path.isfile(location):
yield location
Expand Down Expand Up @@ -283,9 +285,10 @@ def get_relative_path(base_loc, full_loc):
base = norm(base_loc)
path = norm(full_loc)

assert path.startswith(base), (
"Cannot compute relative path: %(path)r does not start with %(base)r" % locals()
)
if not path.startswith(base):
raise ValueError(
f"Cannot compute relative path: {path!r} does not start with {base!r}"
)
base_name = resource_name(base)
no_dir = base == base_name
same_loc = base == path
Expand Down