Skip to content

Commit 27604d6

Browse files
If there is a problem getting the version link from the header file, handle the exception and move on since header.jsonld files seem to be structured inconsistently. Also, not required for rename and upload to work.
1 parent bbf1b16 commit 27604d6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/bdio_update_project_name_and_version.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import zipfile
88
import uuid
99
from zipfile import ZIP_DEFLATED
10+
from urllib.parse import quote
1011

1112
parser = argparse.ArgumentParser("Take a directory of bdio files, copy and unzip each file,"
1213
"update the project and project version name to the name specified by the user,"
@@ -107,10 +108,16 @@ def jsonld_update_version_name_in_header(data, version):
107108
k == 'https://blackducksoftware.github.io/bdio#hasName'}
108109
if not scan_name_dict:
109110
return
110-
version_link = scan_name_dict.popitem()[1].split('/')
111-
version_link[1] = version
112-
version_list = [{'@value': '/'.join(version_link)}]
113-
data.update({'https://blackducksoftware.github.io/bdio#hasName': version_list})
111+
try:
112+
version_link = scan_name_dict.popitem()[1].split('/')
113+
version_link[1] = version
114+
except IndexError as index_error:
115+
logging.debug("Could not get version link for this header file {} with error {}, header files are not "
116+
"required for upload".format(scan_name_dict, index_error))
117+
return
118+
else:
119+
version_list = [{'@value': '/'.join(version_link)}]
120+
data.update({'https://blackducksoftware.github.io/bdio#hasName': version_list})
114121

115122

116123
def jsonld_update_project_version(data, version):

0 commit comments

Comments
 (0)