Skip to content

Commit 373254c

Browse files
author
Michael Schlenker
committed
Simplify conditions and loop
Signed-off-by: Michael Schlenker <[email protected]>
1 parent 35b752c commit 373254c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

cyclonedx_py/_internal/utils/pep639.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,18 @@ def gather_license_texts(
9191
# per spec > license files are stored in the `.dist-info/licenses/` subdirectory of the produced wheel.
9292
# but in practice, other locations are used, too.
9393
# loop over the candidate location and pick the first one found.
94-
malformed = None
9594
content = None
9695
for loc in ('licenses', 'license_files', '.'):
9796
path = join(loc, mlfile)
9897
try:
9998
content = dist.read_text(path)
10099
except UnicodeDecodeError:
101-
# Malformed, stop looking
102-
malformed = path
103-
break
100+
# Malformed, try harder
101+
content = handle_bad_license_file_encoding(dist, mlfile, logger)
104102

105103
if content is not None:
106104
break
107-
108-
if content is None and malformed:
109-
# Try a little harder
110-
content = handle_bad_license_file_encoding(dist, malformed, logger)
111-
112-
if content is None:
105+
else:
113106
logger.debug('Error: failed to read license file %r for dist %r',
114107
mlfile, dist.metadata['Name'])
115108
continue

0 commit comments

Comments
 (0)