def set_pkg_license_declared(self, doc, lic): """Sets the package's declared license. Raises SPDXValueError if data malformed. Raises OrderError if no package previously defined. Raises CardinalityError if already set. """ self.assert_package_exists() if not self.package_license_declared_set: self.package_license_declared_set = True if validations.validate_lics_conc(lic): doc.package.license_declared = lic return True else: raise SPDXValueError('Package::LicenseDeclared') else: raise CardinalityError('Package::LicenseDeclared')
def set_snip_concluded_license(self, doc, conc_lics): """ Raises OrderError if no snippet previously defined. Raises CardinalityError if already set. Raises SPDXValueError if the data is a malformed value. """ self.assert_snippet_exists() if not self.snippet_conc_lics_set: self.snippet_conc_lics_set = True if validations.validate_lics_conc(conc_lics): doc.snippet[-1].conc_lics = conc_lics return True else: raise SPDXValueError('Snippet::SnippetLicenseConcluded') else: raise CardinalityError('Snippet::SnippetLicenseConcluded')
def set_pkg_licenses_concluded(self, doc, licenses): """Sets the package's concluded licenses. licenses - License info. Raises CardinalityError if already defined. Raises OrderError if no package previously defined. Raises SPDXValueError if data malformed. """ self.assert_package_exists() if not self.package_conc_lics_set: self.package_conc_lics_set = True if validations.validate_lics_conc(licenses): doc.package.conc_lics = licenses return True else: raise SPDXValueError('Package::ConcludedLicenses') else: raise CardinalityError('Package::ConcludedLicenses')
def set_concluded_license(self, doc, lic): """ Raises OrderError if no package or file defined. Raises CardinalityError if already set. Raises SPDXValueError if malformed. """ if self.has_package(doc) and self.has_file(doc): if not self.file_conc_lics_set: self.file_conc_lics_set = True if validations.validate_lics_conc(lic): self.file(doc).conc_lics = lic return True else: raise SPDXValueError('File::ConcludedLicense') else: raise CardinalityError('File::ConcludedLicense') else: raise OrderError('File::ConcludedLicense')