Skip to content

Commit 2f48a6a

Browse files
committed
Fixed #431
* Add code to check if "_file" field is empty before the copying process.
1 parent a373c3f commit 2f48a6a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docs/CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
* Enhance the `transform` to also work with JSON file
55
* Update transform code (See #427 and #428)
6+
* Fixed #431 - Error handling for empty "_file" fields
67

78
2020-05-05
89
Release 4.0.2

src/attributecode/util.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,16 @@ def copy_license_notice_files(fields, base_dir, reference_dir, afp):
432432
where reference license an notice files are stored and the `afp`
433433
about_file_path value, this function will copy to the base_dir the
434434
license_file or notice_file if found in the reference_dir
435-
436435
"""
437-
lic_name = ''
436+
copy_file_name = ''
438437
for key, value in fields:
439438
if key == 'license_file' or key == 'notice_file':
440-
lic_name = value
439+
if value:
440+
copy_file_name = value
441+
else:
442+
continue
441443

442-
from_lic_path = posixpath.join(to_posix(reference_dir), lic_name)
444+
from_lic_path = posixpath.join(to_posix(reference_dir), copy_file_name)
443445
about_file_dir = os.path.dirname(to_posix(afp)).lstrip('/')
444446
to_lic_path = posixpath.join(to_posix(base_dir), about_file_dir)
445447

0 commit comments

Comments
 (0)