← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:unused-query-methods into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:unused-query-methods into launchpad:master.

Commit message:
Remove several unused model query methods

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/395725
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:unused-query-methods into launchpad:master.
diff --git a/lib/lp/bugs/model/cve.py b/lib/lp/bugs/model/cve.py
index 553bff3..8f5535d 100644
--- a/lib/lp/bugs/model/cve.py
+++ b/lib/lp/bugs/model/cve.py
@@ -187,20 +187,6 @@ class CveSet:
 
         return sorted(cves, key=lambda a: a.sequence)
 
-    def inMessage(self, message):
-        """See ICveSet."""
-        cves = set()
-        for messagechunk in message:
-            if messagechunk.blob is not None:
-                # we don't process attachments
-                continue
-            elif messagechunk.content is not None:
-                # look for potential CVE URL's and create them as needed
-                cves.update(self.inText(messagechunk.content))
-            else:
-                raise AssertionError('MessageChunk without content or blob.')
-        return sorted(cves, key=lambda a: a.sequence)
-
     def getBugCvesForBugTasks(self, bugtasks, cve_mapper=None):
         """See ICveSet."""
         bugs = bulk.load_related(Bug, bugtasks, ('bug_id', ))
diff --git a/lib/lp/registry/interfaces/distroseries.py b/lib/lp/registry/interfaces/distroseries.py
index aee712f..624c7ce 100644
--- a/lib/lp/registry/interfaces/distroseries.py
+++ b/lib/lp/registry/interfaces/distroseries.py
@@ -715,13 +715,6 @@ class IDistroSeriesPublic(
         list for this distroseries.
         """
 
-    def getSectionByName(name):
-        """Get the named section.
-
-        Raise NotFoundError if the section is not in the permitted section
-        list for this distroseries.
-        """
-
     def addSection(section):
         """SQLObject provided method to fill a related join key section."""
 
diff --git a/lib/lp/registry/interfaces/gpg.py b/lib/lp/registry/interfaces/gpg.py
index 2ae0226..0489cff 100644
--- a/lib/lp/registry/interfaces/gpg.py
+++ b/lib/lp/registry/interfaces/gpg.py
@@ -82,9 +82,6 @@ class IGPGKeySet(Interface):
         inactive ones.
         """
 
-    def getByFingerprints(fingerprints):
-        """Get multiple OpenPGP keys by their fingerprints."""
-
     def getGPGKeysForPerson(person, active=True):
         """Return OpenGPG keys for a person.
 
diff --git a/lib/lp/registry/interfaces/product.py b/lib/lp/registry/interfaces/product.py
index b386fca..326bcb7 100644
--- a/lib/lp/registry/interfaces/product.py
+++ b/lib/lp/registry/interfaces/product.py
@@ -69,7 +69,6 @@ from zope.schema import (
     Text,
     TextLine,
     )
-from zope.schema.vocabulary import SimpleVocabulary
 
 from lp import _
 from lp.answers.interfaces.faqtarget import IFAQTarget
@@ -826,9 +825,6 @@ class IProductView(
     def getMilestonesAndReleases():
         """Return all the milestones and releases for this product."""
 
-    def packagedInDistros():
-        """Returns the distributions this product has been packaged in."""
-
     def userCanEdit(user):
         """Can the user edit this product?"""
 
diff --git a/lib/lp/registry/interfaces/wikiname.py b/lib/lp/registry/interfaces/wikiname.py
index 015d1b9..aecbe9d 100644
--- a/lib/lp/registry/interfaces/wikiname.py
+++ b/lib/lp/registry/interfaces/wikiname.py
@@ -47,12 +47,6 @@ class IWikiName(IHasOwner):
 class IWikiNameSet(Interface):
     """The set of WikiNames."""
 
-    def getByWikiAndName(wiki, wikiname):
-        """Return the WikiName with the given wiki and wikiname.
-
-        Return None if it doesn't exists.
-        """
-
     def get(id):
         """Return the WikiName with the given id or None."""
 
diff --git a/lib/lp/registry/model/accesspolicy.py b/lib/lp/registry/model/accesspolicy.py
index 871291c..2e8fddf 100644
--- a/lib/lp/registry/model/accesspolicy.py
+++ b/lib/lp/registry/model/accesspolicy.py
@@ -23,7 +23,6 @@ from storm.expr import (
     Or,
     Select,
     SQL,
-    With,
     )
 from storm.properties import (
     DateTime,
@@ -51,7 +50,6 @@ from lp.registry.interfaces.accesspolicy import (
     IAccessPolicySource,
     )
 from lp.registry.model.person import Person
-from lp.registry.model.teammembership import TeamParticipation
 from lp.services.database.bulk import create
 from lp.services.database.decoratedresultset import DecoratedResultSet
 from lp.services.database.enumcol import DBEnum
@@ -516,91 +514,6 @@ class AccessPolicyGrantFlat(StormBase):
             result_decorator=set_permission, pre_iter_hook=load_permissions)
 
     @classmethod
-    def _populateIndirectGranteePermissions(cls,
-                                            policies_by_id, result_set):
-        # A cache for the sharing permissions, keyed on grantee.
-        permissions_cache = defaultdict(dict)
-        # A cache of teams belonged to, keyed by grantee.
-        via_teams_cache = defaultdict(list)
-        grantees_by_id = defaultdict()
-        # Information types for which there are shared artifacts.
-        shared_artifact_info_types = defaultdict(list)
-
-        def set_permission(grantee):
-            # Lookup the permissions from the previously loaded cache.
-            via_team_ids = via_teams_cache[grantee[0].id]
-            via_teams = sorted(
-                [grantees_by_id[team_id] for team_id in via_team_ids],
-                key=lambda x: x.displayname)
-            permissions = permissions_cache[grantee[0]]
-            shared_info_types = shared_artifact_info_types[grantee[0]]
-            # For access via teams, we need to use the team permissions. If a
-            # person has access via more than one team, we use the most
-            # powerful permission of all that are there.
-            for team in via_teams:
-                team_permissions = permissions_cache[team]
-                shared_info_types = []
-                for info_type, permission in team_permissions.items():
-                    permission_to_use = permissions.get(info_type, permission)
-                    if permission == SharingPermission.ALL:
-                        permission_to_use = permission
-                    elif permission == SharingPermission.SOME:
-                        shared_info_types.append(info_type.type)
-                    permissions[info_type] = permission_to_use
-            result = (
-                grantee[0], permissions, via_teams or None,
-                shared_info_types)
-            return result
-
-        def load_teams_and_permissions(grantees):
-            # We now have the grantees we want in the result so load any
-            # associated team memberships and permissions and cache them.
-            if permissions_cache:
-                return
-            store = IStore(cls)
-            for grantee in grantees:
-                grantees_by_id[grantee[0].id] = grantee[0]
-            # Find any teams associated with the grantees. If grantees is a
-            # sliced list (for batching), it may contain indirect grantees but
-            # not the team they belong to so that needs to be fixed below.
-            with_expr = With("grantees", store.find(
-                cls.grantee_id, cls.policy_id.is_in(policies_by_id.keys())
-                ).config(distinct=True)._get_select())
-            result_set = store.with_(with_expr).find(
-                (TeamParticipation.teamID, TeamParticipation.personID),
-                TeamParticipation.personID.is_in(grantees_by_id.keys()),
-                TeamParticipation.teamID.is_in(
-                    Select(
-                        (SQL("grantees.grantee"),),
-                        tables="grantees",
-                        distinct=True)))
-            team_ids = set()
-            direct_grantee_ids = set()
-            for team_id, team_member_id in result_set:
-                if team_member_id == team_id:
-                    direct_grantee_ids.add(team_member_id)
-                else:
-                    via_teams_cache[team_member_id].append(team_id)
-                    team_ids.add(team_id)
-            # Remove from the via_teams cache all the direct grantees.
-            for direct_grantee_id in direct_grantee_ids:
-                if direct_grantee_id in via_teams_cache:
-                    del via_teams_cache[direct_grantee_id]
-            # Load and cache the additional required teams.
-            persons = store.find(Person, Person.id.is_in(team_ids))
-            for person in persons:
-                grantees_by_id[person.id] = person
-
-            cls._populatePermissionsCache(
-                permissions_cache, shared_artifact_info_types,
-                grantees_by_id.keys(), policies_by_id, grantees_by_id)
-
-        return DecoratedResultSet(
-            result_set,
-            result_decorator=set_permission,
-            pre_iter_hook=load_teams_and_permissions)
-
-    @classmethod
     def findArtifactsByGrantee(cls, grantee, policies):
         """See `IAccessPolicyGrantFlatSource`."""
         ids = [policy.id for policy in policies]
diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
index c3d8420..ae88622 100644
--- a/lib/lp/registry/model/distroseries.py
+++ b/lib/lp/registry/model/distroseries.py
@@ -1175,16 +1175,6 @@ class DistroSeries(SQLBase, BugTargetBase, HasSpecificationsMixin,
             return comp
         raise NotFoundError(name)
 
-    def getSectionByName(self, name):
-        """See `IDistroSeries`."""
-        section = Section.byName(name)
-        if section is None:
-            raise NotFoundError(name)
-        permitted = set(self.sections)
-        if section in permitted:
-            return section
-        raise NotFoundError(name)
-
     def searchPackages(self, text):
         """See `IDistroSeries`."""
         find_spec = (
diff --git a/lib/lp/registry/model/gpgkey.py b/lib/lp/registry/model/gpgkey.py
index 921bf57..bda1415 100644
--- a/lib/lp/registry/model/gpgkey.py
+++ b/lib/lp/registry/model/gpgkey.py
@@ -18,7 +18,6 @@ from lp.registry.interfaces.gpg import (
     IGPGKeySet,
     )
 from lp.services.database.enumcol import EnumCol
-from lp.services.database.interfaces import IStore
 from lp.services.database.sqlbase import (
     SQLBase,
     sqlvalues,
@@ -103,12 +102,6 @@ class GPGKeySet:
             return default
         return result
 
-    def getByFingerprints(self, fingerprints):
-        """See `IGPGKeySet`"""
-        fingerprints = list(fingerprints)
-        return list(IStore(GPGKey).find(
-            GPGKey, GPGKey.fingerprint.is_in(fingerprints)))
-
     def getGPGKeysForPerson(self, owner, active=True):
         if active is False:
             query = """
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index cc53373..a0beae5 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -4197,10 +4197,6 @@ class WikiName(SQLBase, HasOwnerMixin):
 @implementer(IWikiNameSet)
 class WikiNameSet:
 
-    def getByWikiAndName(self, wiki, wikiname):
-        """See `IWikiNameSet`."""
-        return WikiName.selectOneBy(wiki=wiki, wikiname=wikiname)
-
     def get(self, id):
         """See `IWikiNameSet`."""
         try:
diff --git a/lib/lp/registry/model/product.py b/lib/lp/registry/model/product.py
index 07d652e..5ab5d1b 100644
--- a/lib/lp/registry/model/product.py
+++ b/lib/lp/registry/model/product.py
@@ -1396,15 +1396,6 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements,
         return DecoratedResultSet(
             get_milestones_and_releases([self]), strip_product_id)
 
-    def packagedInDistros(self):
-        return IStore(Distribution).find(
-            Distribution,
-            Packaging.productseriesID == ProductSeries.id,
-            ProductSeries.product == self,
-            Packaging.distroseriesID == DistroSeries.id,
-            DistroSeries.distributionID == Distribution.id,
-            ).config(distinct=True).order_by(Distribution.name)
-
     def composeCustomLanguageCodeMatch(self):
         """See `HasCustomLanguageCodesMixin`."""
         return CustomLanguageCode.product == self
diff --git a/lib/lp/registry/model/sharingjob.py b/lib/lp/registry/model/sharingjob.py
index 04e2daa..7d10fa9 100644
--- a/lib/lp/registry/model/sharingjob.py
+++ b/lib/lp/registry/model/sharingjob.py
@@ -193,10 +193,6 @@ class SharingJobDerived(
             return self.distro
 
     @property
-    def pillar_text(self):
-        return self.pillar.displayname if self.pillar else 'all pillars'
-
-    @property
     def log_name(self):
         return self.__class__.__name__
 
diff --git a/lib/lp/registry/tests/test_product.py b/lib/lp/registry/tests/test_product.py
index bf64c64..bc4f5fd 100644
--- a/lib/lp/registry/tests/test_product.py
+++ b/lib/lp/registry/tests/test_product.py
@@ -879,7 +879,7 @@ class TestProduct(TestCaseWithFactory):
             'license_info', 'license_status', 'licenses', 'milestones',
             'mugshot', 'newCodeImport',
             'obsolete_translatable_series', 'official_bug_tags',
-            'packagedInDistros', 'packagings',
+            'packagings',
             'past_sprints', 'personHasDriverRights',
             'primary_translatable', 'private_bugs',
             'programminglang', 'qualifies_for_free_hosting',
diff --git a/lib/lp/translations/interfaces/potemplate.py b/lib/lp/translations/interfaces/potemplate.py
index 4a630ba..c068f8b 100644
--- a/lib/lp/translations/interfaces/potemplate.py
+++ b/lib/lp/translations/interfaces/potemplate.py
@@ -635,11 +635,6 @@ class IPOTemplateSet(Interface):
         arguments.
         """
 
-    def getSubsetFromImporterSourcePackageName(
-        distroseries, sourcepackagename, iscurrent=None):
-        """Return a POTemplateSubset based on the origin sourcepackagename.
-        """
-
     def getPOTemplateByPathAndOrigin(path, productseries=None,
         distroseries=None, sourcepackagename=None):
         """Return an `IPOTemplate` that is stored at 'path' in source code and
diff --git a/lib/lp/translations/interfaces/rosettastats.py b/lib/lp/translations/interfaces/rosettastats.py
index 7b5b27c..bd3d1d5 100644
--- a/lib/lp/translations/interfaces/rosettastats.py
+++ b/lib/lp/translations/interfaces/rosettastats.py
@@ -73,11 +73,6 @@ class IRosettaStats(Interface):
     def currentPercentage(language=None):
         """Return the percentage of current msgsets inside this object."""
 
-    def rosettaPercentage(language=None):
-        """Return the percentage of msgsets translated with Rosetta inside
-        this object.
-        """
-
     def translatedPercentage(language=None):
         """Return the percentage of msgsets translated for this object."""
 
diff --git a/lib/lp/translations/interfaces/translationimportqueue.py b/lib/lp/translations/interfaces/translationimportqueue.py
index b8c20d3..7c292eb 100644
--- a/lib/lp/translations/interfaces/translationimportqueue.py
+++ b/lib/lp/translations/interfaces/translationimportqueue.py
@@ -273,9 +273,6 @@ class ITranslationImportQueueEntry(Interface):
 
         Return None if we cannot guess it."""
 
-    def getFileContent():
-        """Return the imported file content as a stream."""
-
     def getTemplatesOnSameDirectory():
         """Return import queue entries stored on the same directory as self.
 
diff --git a/lib/lp/translations/model/distroserieslanguage.py b/lib/lp/translations/model/distroserieslanguage.py
index 28e79d7..178ce47 100644
--- a/lib/lp/translations/model/distroserieslanguage.py
+++ b/lib/lp/translations/model/distroserieslanguage.py
@@ -222,9 +222,6 @@ class DummyDistroSeriesLanguage(RosettaStats):
     def currentPercentage(self, language=None):
         return 0.0
 
-    def rosettaPercentage(self, language=None):
-        return 0.0
-
     def updatesPercentage(self, language=None):
         return 0.0
 
diff --git a/lib/lp/translations/model/pofile.py b/lib/lp/translations/model/pofile.py
index ff8ac2c..b6af3e7 100644
--- a/lib/lp/translations/model/pofile.py
+++ b/lib/lp/translations/model/pofile.py
@@ -1348,10 +1348,6 @@ class DummyPOFile(POFileMixIn):
         """See `IRosettaStats`."""
         return 0.0
 
-    def rosettaPercentage(self, language=None):
-        """See `IRosettaStats`."""
-        return 0.0
-
     def updatesPercentage(self, language=None):
         """See `IRosettaStats`."""
         return 0.0
diff --git a/lib/lp/translations/model/potemplate.py b/lib/lp/translations/model/potemplate.py
index ebdbc42..0b05e25 100644
--- a/lib/lp/translations/model/potemplate.py
+++ b/lib/lp/translations/model/potemplate.py
@@ -1305,18 +1305,6 @@ class POTemplateSet:
             iscurrent=iscurrent,
             ordered_by_names=ordered_by_names)
 
-    def getSubsetFromImporterSourcePackageName(self, distroseries,
-        sourcepackagename, iscurrent=None):
-        """See `IPOTemplateSet`."""
-        if distroseries is None or sourcepackagename is None:
-            raise AssertionError(
-                'distroseries and sourcepackage must be not None.')
-
-        return POTemplateSubset(
-            distroseries=distroseries,
-            sourcepackagename=sourcepackagename,
-            iscurrent=iscurrent)
-
     def getSharingSubset(self, distribution=None, sourcepackagename=None,
                          product=None):
         """See `IPOTemplateSet`."""
diff --git a/lib/lp/translations/model/translationimportqueue.py b/lib/lp/translations/model/translationimportqueue.py
index 21e6112..f88ed94 100644
--- a/lib/lp/translations/model/translationimportqueue.py
+++ b/lib/lp/translations/model/translationimportqueue.py
@@ -32,7 +32,6 @@ from storm.locals import (
     DateTime,
     Int,
     Reference,
-    Store,
     Unicode,
     )
 from zope.component import (
@@ -804,11 +803,6 @@ class TranslationImportQueueEntry(StormBase):
                 lang_code, translation_domain,
                 sourcepackagename=self.sourcepackagename)
 
-    def getFileContent(self):
-        """See ITranslationImportQueueEntry."""
-        client = getUtility(ILibrarianClient)
-        return client.getFileByAlias(self.content.id).read()
-
     def getTemplatesOnSameDirectory(self):
         """See ITranslationImportQueueEntry."""
         importer = getUtility(ITranslationImporter)
diff --git a/lib/lp/translations/utilities/rosettastats.py b/lib/lp/translations/utilities/rosettastats.py
index d8340fc..642ec25 100644
--- a/lib/lp/translations/utilities/rosettastats.py
+++ b/lib/lp/translations/utilities/rosettastats.py
@@ -103,7 +103,3 @@ class RosettaStats(object):
     def updatesPercentage(self, language=None):
         """See IRosettaStats."""
         return self.asPercentage(self.updatesCount(language))
-
-    def rosettaPercentage(self, language=None):
-        """See IRosettaStats."""
-        return self.asPercentage(self.rosettaCount(language))