def set_doc_version(self, doc, value): """ Set the document version. Raise exceptions: - SPDXValueError if malformed value, - CardinalityError if already defined, - IncompatibleVersionError if not 1.2. """ # FIXME: relax version supported if not self.doc_version_set: self.doc_version_set = True m = self.VERS_STR_REGEX.match(value) if m is None: raise SPDXValueError('Document::Version') else: vers = version.Version(major=int(m.group(1)), minor=int(m.group(2))) # FIXME: we can deal with newer versions too if vers == version.Version(major=1, minor=2): doc.version = vers return True else: raise IncompatibleVersionError(value) else: raise CardinalityError('Document::Version')
def set_doc_version(self, doc, value): """Sets the document version. Raises value error if malformed value, CardinalityError if already defined, IncompatibleVersionError if not 1.2. """ if not self.doc_version_set: self.doc_version_set = True m = self.VERS_STR_REGEX.match(value) if m is None: raise SPDXValueError('Document::Version') else: vers = version.Version(major=int(m.group(1)), minor=int(m.group(2))) if vers == version.Version(major=1, minor=2): doc.version = vers return True else: raise IncompatibleVersionError(value) else: raise CardinalityError('Document::Version')
def set_doc_version(self, doc, value): """ Set the document version. Raise SPDXValueError if malformed value. Raise CardinalityError if already defined. """ if not self.doc_version_set: self.doc_version_set = True m = self.VERS_STR_REGEX.match(value) if m is None: raise SPDXValueError("Document::Version") else: doc.version = version.Version(major=int(m.group(1)), minor=int(m.group(2))) return True else: raise CardinalityError("Document::Version")
def create_document(token: str) -> Document: logging.debug(f"Creating SBOM Document section") global ws_conn scope_name = ws_conn.get_scope_name_by_token(token) document = Document(name=f"WhiteSource {scope_name} SBOM report", namespace=extra_conf.get('namespace'), spdx_id="SPDXRef-DOCUMENT", version=version.Version(2, 2), data_license=License.from_identifier("CC0-1.0")) logging.debug(f"Creating SBOM Creation Info section") document.creation_info.set_created_now() org = creationinfo.Organization(ws_conn.get_name(), extra_conf.get('org_email')) tool = creationinfo.Tool("White Source SBOM Report Generator") person = creationinfo.Person(extra_conf.get('person'), extra_conf.get('person_email')) document.creation_info.add_creator(org) document.creation_info.add_creator(tool) document.creation_info.add_creator(person) logging.debug(f"Finished SBOM Document section") return document