def get_licenses(self, pfmri=None): """A generator function that yields information about the licenses related to the current plan in tuples of the form (dest_fmri, src, dest, accepted, displayed) for the given package FMRI or all packages in the plan. This is only available for licenses that are being installed or updated. 'dest_fmri' is the FMRI of the package being installed. 'src' is a LicenseInfo object if the license of the related package is being updated; otherwise it is None. 'dest' is the LicenseInfo object for the license that is being installed. 'accepted' is a boolean value indicating that the license has been marked as accepted for the current plan. 'displayed' is a boolean value indicating that the license has been marked as displayed for the current plan.""" for pp in self.pkg_plans: dfmri = pp.destination_fmri if pfmri and dfmri != pfmri: continue # Unused variable; pylint: disable=W0612 for lid, entry in pp.get_licenses(): src = entry["src"] src_li = None if src: src_li = LicenseInfo(pp.origin_fmri, src, img=pp.image) dest = entry["dest"] dest_li = None if dest: dest_li = LicenseInfo( pp.destination_fmri, dest, img=pp.image) yield (pp.destination_fmri, src_li, dest_li, entry["accepted"], entry["displayed"]) if pfmri: break
def __licenses(self, mfst): """Private function. Returns the license info from the manifest mfst.""" license_lst = [] for lic in mfst.gen_actions_by_type("license"): s = StringIO.StringIO() lpath = self._depot.repo.file(lic.hash, pub=self._pub) lfile = file(lpath, "rb") misc.gunzip_from_stream(lfile, s, ignore_hash=True) text = s.getvalue() s.close() license_lst.append(LicenseInfo(mfst.fmri, lic, text=text)) return license_lst