Skip to content

Commit e2e569a

Browse files
authored
Merge pull request #114 from blackducksoftware/gsnyder/adding-parameter-for-including-copyright-info
adding support for invoking the option to include (or exclude) additional copyright information from notices file report
2 parents 0a25777 + 4cf221b commit e2e569a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

blackduck/HubRestApi.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,17 @@ def create_version_reports(self, version, report_list, format="CSV"):
560560
return self.execute_post(version_reports_url, post_data)
561561

562562
valid_notices_formats = ["TEXT", "JSON"]
563-
def create_version_notices_report(self, version, format="TEXT"):
563+
def create_version_notices_report(self, version, format="TEXT", include_copyright_info=True):
564564
assert format in HubInstance.valid_notices_formats, "Format must be one of {}".format(HubInstance.valid_notices_formats)
565565

566566
post_data = {
567-
'categories': ["COPYRIGHT_TEXT"],
568-
'versionId': version['_meta']['href'].split("/")[-1],
567+
'versionId': object_id(version),
569568
'reportType': 'VERSION_LICENSE',
570569
'reportFormat': format
571570
}
571+
if include_copyright_info:
572+
post_data.update({'categories': ["COPYRIGHT_TEXT"] })
573+
572574
notices_report_url = self.get_link(version, 'licenseReports')
573575
return self.execute_post(notices_report_url, post_data)
574576

blackduck/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = (0, 0, 53)
1+
VERSION = (0, 0, 54)
22

33
__version__ = '.'.join(map(str, VERSION))

examples/generate_notices_report_for_project_version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
parser.add_argument('-f', "--file_name_base", default="notices_report", help="Base file name to write the report data into. If the report format is TEXT a .zip file will be created, otherwise a .json file")
2525
parser.add_argument('-r', '--report_format', default='TEXT', choices=["JSON", "TEXT"], help="Report format - choices are TEXT or HTML")
26+
parser.add_argument('-c', '--include_copyright_info', action='store_true', help="Set this option to have additional copyright information from the Black Duck KB included in the notices file report.")
2627

2728
args = parser.parse_args()
2829

@@ -66,7 +67,7 @@ def download_report(location, file_name_base, retries=10):
6667
if project:
6768
version = hub.get_version_by_name(project, args.version_name)
6869

69-
response = hub.create_version_notices_report(version, args.report_format)
70+
response = hub.create_version_notices_report(version, args.report_format, include_copyright_info=args.include_copyright_info)
7071

7172
if response.status_code == 201:
7273
logging.info("Successfully created notices report in {} format for project {} and version {}".format(

0 commit comments

Comments
 (0)