def ResetNameProperty(self): """Sometimes, NAME= contains useless data. This method resets them.""" pkginfo_dict = self.GetParsedPkginfo() catalog_name = opencsw.PkgnameToCatName(pkginfo_dict["PKG"]) description = pkginfo_dict["DESC"] pkginfo_name = "%s - %s" % (catalog_name, description) self.SetPkginfoEntry("NAME", pkginfo_name)
def _GetFakeSrv4(self, pkgname, osrel, arch): """Retrieves or creates a fake srv4 object.""" key = (pkgname, osrel, arch) if key not in self.fake_srv4_cache: sqo_pkginst = self._GetPkginst(pkgname) fake_srv4_md5 = self.ComposeFakeSrv4Md5(pkgname, osrel, arch) sqo_osrel, sqo_arch = self._GetSqoOsrelAndArch(osrel, arch) # logging.debug("_GetFakeSrv4(%s, %s, %s), %s", # pkgname, osrel, arch, fake_srv4_md5) try: sqo_srv4 = m.Srv4FileStats.select( m.Srv4FileStats.q.md5_sum==fake_srv4_md5).getOne() except sqlobject.main.SQLObjectNotFound, e: catalogname = opencsw.PkgnameToCatName(pkgname) maintainer = self._GetFakeMaintainer() sqo_srv4 = m.Srv4FileStats( arch=sqo_arch, basename=("%s-fake_version" % catalogname), catalogname=catalogname, data_obj=None, use_to_generate_catalogs=False, filename_arch=sqo_arch, latest=True, maintainer=maintainer, md5_sum=fake_srv4_md5, mtime=datetime.datetime.now(), os_rel=sqo_osrel, pkginst=sqo_pkginst, registered=True, rev="fake_rev", stats_version=package_stats.PACKAGE_STATS_VERSION, version_string="fake_version", size=0) self.fake_srv4_cache[key] = sqo_srv4
def testPkgnameToCatName4(self): self.assertEquals("stuf_with_some_dashes", opencsw.PkgnameToCatName("STUFwith-some-dashes"))
def testPkgnameToCatName5(self): self.assertNotEquals(opencsw.PkgnameToCatName("SUNWi4rf"), opencsw.PkgnameToCatName("SUNWi7rf"))
def testPkgnameToCatName3(self): """These are the rules!""" self.assertEquals("sunw_p_ython", opencsw.PkgnameToCatName("SUNWPython"))
def testPkgnameToCatName2(self): self.assertEquals("sunw_bash_s", opencsw.PkgnameToCatName("SUNWbashS"))
def testPkgnameToCatNameTwoDigits(self): self.assertEquals("sunw_i13rf", opencsw.PkgnameToCatName("SUNWi13rf"))
def testPkgnameToCatNameDigit(self): self.assertEquals("sunw_i8rf", opencsw.PkgnameToCatName("SUNWi8rf"))
def testPkgnameToCatNameDifferentiatesByDigit(self): self.assertNotEquals(opencsw.PkgnameToCatName("SUNWi4rf"), opencsw.PkgnameToCatName("SUNWi7rf"))