launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15537
[Merge] lp:~stevenk/launchpad/is_empty-is-the-new-black into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/is_empty-is-the-new-black into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/is_empty-is-the-new-black/+merge/162177
Stop using .count() > 0, .count() != 0 and .count() > 1 and replace them with my new best friend, .is_empty().
--
https://code.launchpad.net/~stevenk/launchpad/is_empty-is-the-new-black/+merge/162177
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/is_empty-is-the-new-black into lp:launchpad.
=== modified file 'lib/lp/app/browser/tales.py'
--- lib/lp/app/browser/tales.py 2013-05-01 18:39:38 +0000
+++ lib/lp/app/browser/tales.py 2013-05-02 17:02:45 +0000
@@ -955,11 +955,11 @@
def _hasBugBranch(self):
"""Return whether the bug has a branch linked to it."""
- return self._context.bug.linked_branches.count() > 0
+ return not self._context.bug.linked_branches.is_empty()
def _hasSpecification(self):
"""Return whether the bug is linked to a specification."""
- return self._context.bug.specifications.count() > 0
+ return not self._context.bug.specifications.is_empty()
def _hasPatch(self):
"""Return whether the bug has a patch."""
=== modified file 'lib/lp/app/stories/basics/xx-dbpolicy.txt'
--- lib/lp/app/stories/basics/xx-dbpolicy.txt 2012-09-28 07:11:03 +0000
+++ lib/lp/app/stories/basics/xx-dbpolicy.txt 2013-05-02 17:02:45 +0000
@@ -36,10 +36,10 @@
... MAIN_STORE, SLAVE_FLAVOR)
>>> master_store = getUtility(IStoreSelector).get(
... MAIN_STORE, MASTER_FLAVOR)
- >>> slave_store.find(Person).count()
- 0
- >>> master_store.find(Person).count() > 0
+ >>> slave_store.find(Person).is_empty()
True
+ >>> master_store.find(Person).is_empty()
+ False
This helper parses the output of the +whichdb view (which unfortunately
needs to be created externally to this pagetest).
=== modified file 'lib/lp/archivepublisher/domination.py'
--- lib/lp/archivepublisher/domination.py 2013-02-25 04:24:16 +0000
+++ lib/lp/archivepublisher/domination.py 2013-05-02 17:02:45 +0000
@@ -531,7 +531,7 @@
'BinaryPackageBuild'])
# There is at least one non-removed binary to consider
- if considered_binaries.count() > 0:
+ if not considered_binaries.is_empty():
# However we can still remove *this* record if there's
# at least one other PUBLISHED for the spr. This happens
# when a package is moved between components.
@@ -543,7 +543,7 @@
sourcepackagereleaseID=srcpkg_release.id)
# Zero PUBLISHED for this spr, so nothing to take over
# for us, so leave it for consideration next time.
- if published.count() == 0:
+ if published.is_empty():
continue
# Okay, so there's no unremoved binaries, let's go for it...
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2013-02-25 04:13:16 +0000
+++ lib/lp/archivepublisher/publishing.py 2013-05-02 17:02:45 +0000
@@ -319,7 +319,7 @@
# Make the source publications query.
source_query = " AND ".join(clauses)
sources = SourcePackagePublishingHistory.select(source_query)
- if sources.count() > 0:
+ if not sources.is_empty():
self.markPocketDirty(distroseries, pocket)
# No need to check binaries if the pocket is already
# dirtied from a source.
@@ -334,7 +334,7 @@
binary_query = " AND ".join(clauses)
binaries = BinaryPackagePublishingHistory.select(binary_query,
clauseTables=['DistroArchSeries'])
- if binaries.count() > 0:
+ if not binaries.is_empty():
self.markPocketDirty(distroseries, pocket)
def B_dominate(self, force_domination):
=== modified file 'lib/lp/bugs/browser/bugtracker.py'
--- lib/lp/bugs/browser/bugtracker.py 2013-05-01 18:49:40 +0000
+++ lib/lp/bugs/browser/bugtracker.py 2013-05-02 17:02:45 +0000
@@ -359,7 +359,7 @@
# Only admins and registry experts can delete bug watches en
# masse.
- if self.context.watches.count() > 0:
+ if not self.context.watches.is_empty():
admin_teams = [celebrities.admin, celebrities.registry_experts]
for team in admin_teams:
if self.user.inTeam(team):
@@ -371,7 +371,7 @@
sorted(team.title for team in admin_teams)))
# Bugtrackers with imported messages cannot be deleted.
- if self.context.imported_bug_messages.count() > 0:
+ if not self.context.imported_bug_messages.is_empty():
reasons.append(
'Bug comments have been imported via this bug tracker.')
@@ -424,9 +424,7 @@
"""Return True if the user can see the reschedule action."""
user_can_reset_watches = check_permission(
"launchpad.Admin", self.context)
- return (
- user_can_reset_watches and
- self.context.watches.count() > 0)
+ return user_can_reset_watches and not self.context.watches.is_empty()
@action(
'Reschedule all watches', name='reschedule',
=== modified file 'lib/lp/bugs/browser/widgets/bugtask.py'
--- lib/lp/bugs/browser/widgets/bugtask.py 2013-04-11 04:54:04 +0000
+++ lib/lp/bugs/browser/widgets/bugtask.py 2013-05-02 17:02:45 +0000
@@ -272,8 +272,8 @@
user = getUtility(ILaunchBag).user
context = self.context.context
return user is not None and (
- context.userCanSetAnyAssignee(user) or
- user.teams_participated_in.count() > 0)
+ context.userCanSetAnyAssignee(user) or not
+ user.teams_participated_in.is_empty())
class BugWatchEditForm(Interface):
=== modified file 'lib/lp/bugs/doc/externalbugtracker-comment-imports.txt'
--- lib/lp/bugs/doc/externalbugtracker-comment-imports.txt 2012-06-13 21:01:11 +0000
+++ lib/lp/bugs/doc/externalbugtracker-comment-imports.txt 2013-05-02 17:02:45 +0000
@@ -514,8 +514,8 @@
... '3': 'Third imported comment (initial import)',
... '4': 'Fourth imported comment (initial import)',
... }
- >>> bug_watch.getImportedBugMessages().count() > 0
- True
+ >>> bug_watch.getImportedBugMessages().is_empty()
+ False
>>> transaction.commit()
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py 2013-05-01 00:23:31 +0000
+++ lib/lp/bugs/model/bug.py 2013-05-02 17:02:45 +0000
@@ -732,7 +732,7 @@
# view all bugs.
bugtasks = getUtility(IBugTaskSet).findExpirableBugTasks(
days_old, getUtility(ILaunchpadCelebrities).janitor, bug=self)
- return bugtasks.count() > 0
+ return not bugtasks.is_empty()
def isExpirable(self, days_old=None):
"""See `IBug`."""
@@ -757,7 +757,7 @@
# view all bugs.
bugtasks = getUtility(IBugTaskSet).findExpirableBugTasks(
days_old, getUtility(ILaunchpadCelebrities).janitor, bug=self)
- return bugtasks.count() > 0
+ return not bugtasks.is_empty()
@cachedproperty
def initial_message(self):
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2013-04-10 08:09:05 +0000
+++ lib/lp/code/browser/branch.py 2013-05-02 17:02:45 +0000
@@ -761,7 +761,7 @@
params = BugTaskSearchParams(
user=self.user, linked_branches=self.context.id,
information_type=hidden_types)
- if getUtility(IBugTaskSet).searchBugIds(params).count() > 0:
+ if not getUtility(IBugTaskSet).searchBugIds(params).is_empty():
shown_types += hidden_types
# Now take the intersection of the allowed and shown types.
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2013-03-14 06:18:17 +0000
+++ lib/lp/code/model/branch.py 2013-05-02 17:02:45 +0000
@@ -744,8 +744,8 @@
def canBeDeleted(self):
"""See `IBranch`."""
- if ((len(self.deletionRequirements()) != 0) or
- self.getStackedBranches().count() > 0):
+ if ((len(self.deletionRequirements()) != 0) or not
+ self.getStackedBranches().is_empty()):
# Can't delete if the branch is associated with anything.
return False
else:
@@ -1353,7 +1353,7 @@
Job._status != JobStatus.COMPLETED,
Job._status != JobStatus.FAILED,
BranchJob.job_type == BranchJobType.UPGRADE_BRANCH)
- return jobs.count() > 0
+ return not jobs.is_empty()
def requestUpgrade(self, requester):
"""See `IBranch`."""
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2013-02-28 01:02:50 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2013-05-02 17:02:45 +0000
@@ -120,7 +120,7 @@
if from_state in FINAL_STATES and next_state not in FINAL_STATES:
dupes = BranchMergeProposalGetter.activeProposalsForBranches(
proposal.source_branch, proposal.target_branch)
- if dupes.count() > 0:
+ if not dupes.is_empty():
return False
[
=== modified file 'lib/lp/codehosting/scanner/email.py'
--- lib/lp/codehosting/scanner/email.py 2012-04-05 20:30:06 +0000
+++ lib/lp/codehosting/scanner/email.py 2013-05-02 17:02:45 +0000
@@ -24,7 +24,7 @@
BranchSubscriptionNotificationLevel.DIFFSONLY,
BranchSubscriptionNotificationLevel.FULL)
subscriptions = db_branch.getSubscriptionsByLevel(diff_levels)
- return subscriptions.count() > 0
+ return not subscriptions.is_empty()
def send_removed_revision_emails(revisions_removed):
=== modified file 'lib/lp/codehosting/scanner/mergedetection.py'
--- lib/lp/codehosting/scanner/mergedetection.py 2011-03-03 01:13:47 +0000
+++ lib/lp/codehosting/scanner/mergedetection.py 2013-05-02 17:02:45 +0000
@@ -26,7 +26,7 @@
# XXX: JonathanLange 2009-05-07 spec=package-branches: This assumes that
# we only care about whether a branch is a product series. What about poor
# old distroseries?
- return branch.associatedProductSeries().count() > 0
+ return not branch.associatedProductSeries().is_empty()
def is_development_focus(branch):
=== modified file 'lib/lp/hardwaredb/model/hwdb.py'
--- lib/lp/hardwaredb/model/hwdb.py 2013-01-07 02:40:55 +0000
+++ lib/lp/hardwaredb/model/hwdb.py 2013-05-02 17:02:45 +0000
@@ -277,7 +277,7 @@
def submissionIdExists(self, submission_key):
"""See `IHWSubmissionSet`."""
rows = HWSubmission.selectBy(submission_key=submission_key)
- return rows.count() > 0
+ return not rows.is_empty()
def getByStatus(self, status, user=None):
"""See `IHWSubmissionSet`."""
=== modified file 'lib/lp/registry/browser/peoplemerge.py'
--- lib/lp/registry/browser/peoplemerge.py 2012-10-03 04:52:37 +0000
+++ lib/lp/registry/browser/peoplemerge.py 2013-05-02 17:02:45 +0000
@@ -74,7 +74,7 @@
"deleted PPA's files.",
mapping=dict(name=dupe_person.name)))
all_branches = getUtility(IAllBranches)
- if all_branches.ownedBy(dupe_person).isPrivate().count() != 0:
+ if not all_branches.ownedBy(dupe_person).isPrivate().is_empty():
self.addError(
_("${name} owns private branches that must be "
"deleted or transferred to another owner first.",
@@ -172,7 +172,7 @@
we'll ask for confirmation before actually performing the merge.
"""
self.setUpPeople(data)
- if self.dupe_person_emails.count() > 0:
+ if not self.dupe_person_emails.is_empty():
# We're merging a person which has one or more email addresses,
# so we better warn the admin doing the operation and have him
# check the emails that will be reassigned to ensure he's not
@@ -236,7 +236,7 @@
members first.
"""
self.setUpPeople(data)
- if self.dupe_person.activemembers.count() > 0:
+ if not self.dupe_person.activemembers.is_empty():
# Merging teams with active members is not possible, so we'll
# ask the admin if he wants to deactivate all members and then
# merge.
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py 2013-04-10 08:09:05 +0000
+++ lib/lp/registry/browser/person.py 2013-05-02 17:02:45 +0000
@@ -778,7 +778,7 @@
@enabled_with_permission('launchpad.Special')
def editsshkeys(self):
target = '+editsshkeys'
- if self.context.sshkeys.count() == 0:
+ if self.context.sshkeys.is_empty():
text = 'Add an SSH key'
icon = 'add'
else:
@@ -812,7 +812,7 @@
# Only enable the link if the person has some subscriptions.
subscriptions = getUtility(IArchiveSubscriberSet).getBySubscriber(
self.context)
- enabled = subscriptions.count() > 0
+ enabled = not subscriptions.is_empty()
return Link(target, text, summary, enabled=enabled, icon='info')
@@ -1483,7 +1483,7 @@
@cachedproperty
def has_expired_karma(self):
"""Did the person have karma?"""
- return self.context.latestKarma().count() > 0
+ return not self.context.latestKarma().is_empty()
class ContactViaWebLinksMixin:
@@ -1912,7 +1912,7 @@
return True
# If the current user can view any PPA, show the section.
- return self.visible_ppas.count() > 0
+ return not self.visible_ppas.is_empty()
@cachedproperty
def visible_ppas(self):
@@ -2249,7 +2249,7 @@
def setUpFields(self):
super(PersonEditJabberIDsView, self).setUpFields()
- if self.context.jabberids.count() > 0:
+ if not self.context.jabberids.is_empty():
# Make the jabberid entry optional on the edit page if one or more
# ids already exist, which allows the removal of ids without
# filling out the new jabberid field.
@@ -2717,7 +2717,7 @@
"""
# Defaults for the user's email addresses.
validated = self.context.preferredemail
- if validated is None and self.context.validatedemails.count() > 0:
+ if validated is None and not self.context.validatedemails.is_empty():
validated = self.context.validatedemails[0]
unvalidated = self.unvalidated_addresses
if len(unvalidated) > 0:
=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py 2013-04-10 08:09:05 +0000
+++ lib/lp/registry/browser/productseries.py 2013-05-02 17:02:45 +0000
@@ -722,7 +722,7 @@
@cachedproperty
def has_linked_packages(self):
"""Is the series linked to source packages."""
- return self.context.packagings.count() > 0
+ return not self.context.packagings.is_empty()
@cachedproperty
def linked_packages_message(self):
=== modified file 'lib/lp/registry/doc/person-account.txt'
--- lib/lp/registry/doc/person-account.txt 2013-03-12 05:51:28 +0000
+++ lib/lp/registry/doc/person-account.txt 2013-05-02 17:02:45 +0000
@@ -71,8 +71,8 @@
>>> personset = getUtility(IPersonSet)
>>> foobar_preferredemail = emailset.getByEmail('foo.bar@xxxxxxxxxxxxx')
>>> foobar = personset.get(foobar_preferredemail.personID)
- >>> foobar.specifications(None).count() > 0
- True
+ >>> foobar.specifications(None).is_empty()
+ False
>>> from lp.blueprints.model.specification import Specification
>>> from lp.registry.model.person import Person
@@ -98,12 +98,12 @@
>>> from lp.bugs.interfaces.bugtasksearch import BugTaskSearchParams
>>> params = BugTaskSearchParams(foobar, assignee=foobar)
- >>> foobar.searchTasks(params).count() > 0
- True
+ >>> foobar.searchTasks(params).is_empty()
+ False
>>> foobar.specifications(
- ... foobar, filter=[SpecificationFilter.ASSIGNEE]).count() > 0
- True
+ ... foobar, filter=[SpecificationFilter.ASSIGNEE]).is_empty()
+ False
>>> foobar_pillars = []
>>> for pillar_name in foobar.getAffiliatedPillars(foobar):
@@ -170,24 +170,24 @@
...no assigned bug tasks...
- >>> foobar.searchTasks(params).count()
- 0
+ >>> foobar.searchTasks(params).is_empty()
+ True
...no assigned specs...
>>> foobar.specifications(
- ... foobar, filter=[SpecificationFilter.ASSIGNEE]).count()
- 0
+ ... foobar, filter=[SpecificationFilter.ASSIGNEE]).is_empty()
+ True
...no owned teams...
- >>> Person.selectBy(teamowner=foobar).count()
- 0
+ >>> Person.selectBy(teamowner=foobar).is_empty()
+ True
...no owned or driven pillars...
- >>> foobar.getAffiliatedPillars(foobar).count()
- 0
+ >>> foobar.getAffiliatedPillars(foobar).is_empty()
+ True
...and, finally, to not be considered a valid person in Launchpad.
=== modified file 'lib/lp/registry/doc/vocabularies.txt'
--- lib/lp/registry/doc/vocabularies.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/registry/doc/vocabularies.txt 2013-05-02 17:02:45 +0000
@@ -1050,8 +1050,8 @@
'Select a Person'
>>> people = vocab.search(None)
- >>> people.count() > 0
- True
+ >>> people.is_empty()
+ False
>>> invalid_people = [
... person for person in people if not person.is_valid_person]
=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
--- lib/lp/registry/model/distributionsourcepackage.py 2013-01-03 23:10:25 +0000
+++ lib/lp/registry/model/distributionsourcepackage.py 2013-05-02 17:02:45 +0000
@@ -211,10 +211,8 @@
def delete(self):
"""See `DistributionSourcePackage`."""
dsp_in_db = self._self_in_database
- no_spph = self.publishing_history.count() == 0
- if dsp_in_db is not None and no_spph:
- store = IStore(dsp_in_db)
- store.remove(dsp_in_db)
+ if dsp_in_db is not None and self.publishing_history.is_empty():
+ IStore(dsp_in_db).remove(dsp_in_db)
return True
return False
@@ -266,7 +264,7 @@
orderBy='-datecreated',
prejoinClauseTables=['SourcePackageRelease'],
clauseTables=['DistroSeries', 'SourcePackageRelease'])
- if spph.count() == 0:
+ if spph.is_empty():
return None
return DistributionSourcePackageRelease(
distribution=self.distribution,
@@ -362,9 +360,8 @@
def binary_names(self):
"""See `IDistributionSourcePackage`."""
names = []
- history = self.publishing_history
- if history.count() > 0:
- binaries = history[0].getBuiltBinaries()
+ if not self.publishing_history.is_empty():
+ binaries = self.publishing_history[0].getBuiltBinaries()
names = [binary.binary_package_name for binary in binaries]
return names
@@ -377,7 +374,7 @@
DistroSeries.distribution == self.distribution)
result = store.find(Packaging, condition)
result.order_by("debversion_sort_key(version) DESC")
- if result.count() == 0:
+ if result.is_empty():
return None
else:
return result[0].productseries.product
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2013-05-01 00:23:31 +0000
+++ lib/lp/registry/model/person.py 2013-05-02 17:02:45 +0000
@@ -1823,7 +1823,7 @@
"or more if its super teams are not open." % policy)
# Does the team own a productseries.branch?
- if getUtility(IAllBranches).ownedBy(self).isSeries().count() != 0:
+ if not getUtility(IAllBranches).ownedBy(self).isSeries().is_empty():
raise TeamMembershipPolicyError(
"The team membership policy cannot be %s because it owns "
"or more branches linked to project series." % policy)
@@ -2174,7 +2174,7 @@
errors = []
product_set = getUtility(IProductSet)
non_public_products = product_set.get_users_private_products(self)
- if non_public_products.count() != 0:
+ if not non_public_products.is_empty():
errors.append(('This account cannot be deactivated because it owns'
' the following non-public products: ') +
','.join([p.name for p in non_public_products]))
@@ -2980,7 +2980,7 @@
"""See `IPerson`."""
permissions = getUtility(IArchivePermissionSet).componentsForUploader(
distribution.main_archive, self)
- return permissions.count() > 0
+ return not permissions.is_empty()
@cachedproperty
def is_ubuntu_coc_signer(self):
@@ -3089,8 +3089,7 @@
def isBugContributor(self, user=None):
"""See `IPerson`."""
search_params = BugTaskSearchParams(user=user, assignee=self)
- bugtask_count = self.searchTasks(search_params).count()
- return bugtask_count > 0
+ return not self.searchTasks(search_params).is_empty()
def isBugContributorInTarget(self, user=None, target=None):
"""See `IPerson`."""
@@ -3098,8 +3097,7 @@
IProjectGroup.providedBy(target)), (
"%s isn't a valid bug target." % target)
search_params = BugTaskSearchParams(user=user, assignee=self)
- bugtask_count = target.searchTasks(search_params).count()
- return bugtask_count > 0
+ return not target.searchTasks(search_params).is_empty()
@property
def structural_subscriptions(self):
@@ -4253,12 +4251,13 @@
raise AssertionError(
'from_person has a ppa in ACTIVE or DELETING status')
from_person_branches = getUtility(IAllBranches).ownedBy(from_person)
- if from_person_branches.isPrivate().count() != 0:
+ if not from_person_branches.isPrivate().is_empty():
raise AssertionError('from_person has private branches.')
if from_person.is_team:
self._purgeUnmergableTeamArtifacts(
from_person, to_person, reviewer)
- if getUtility(IEmailAddressSet).getByPerson(from_person).count() > 0:
+ if not getUtility(
+ IEmailAddressSet).getByPerson(from_person).is_empty():
raise AssertionError('from_person still has email addresses.')
# Get a database cursor.
=== modified file 'lib/lp/registry/tests/test_distributionmirror_prober.py'
--- lib/lp/registry/tests/test_distributionmirror_prober.py 2013-05-01 22:26:29 +0000
+++ lib/lp/registry/tests/test_distributionmirror_prober.py 2013-05-02 17:02:45 +0000
@@ -839,11 +839,11 @@
def test_MirrorCDImageSeries_records_are_deleted_before_probing(self):
mirror = DistributionMirror.byName('releases-mirror2')
- self.failUnless(mirror.cdimage_series.count() > 0)
+ self.failUnless(not mirror.cdimage_series.is_empty())
# Note that calling this function won't actually probe any mirrors; we
# need to call reactor.run() to actually start the probing.
probe_cdimage_mirror(mirror, StringIO(), [], logging)
- self.failUnlessEqual(mirror.cdimage_series.count(), 0)
+ self.failUnless(mirror.cdimage_series.is_empty())
def test_archive_mirror_probe_function(self):
mirror1 = DistributionMirror.byName('archive-mirror')
=== modified file 'lib/lp/registry/tests/test_karmacache_updater.py'
--- lib/lp/registry/tests/test_karmacache_updater.py 2011-12-30 06:14:56 +0000
+++ lib/lp/registry/tests/test_karmacache_updater.py 2013-05-02 17:02:45 +0000
@@ -58,7 +58,7 @@
# delete the cache entries for Sample Person.
sample_person = self.personset.getByName('name12')
cache_entries = self._getCacheEntriesByPerson(sample_person)
- self.failUnless(cache_entries.count() > 0)
+ self.failUnless(not cache_entries.is_empty())
for cache in cache_entries:
self.failIf(cache.karmavalue <= 0)
@@ -102,4 +102,4 @@
self.failUnless(entries_count <= foobar_original_entries_count)
# And finally, ensure that No Priv got some new KarmaCache entries.
- self.failUnless(self._getCacheEntriesByPerson(nopriv).count() > 0)
+ self.failUnless(not self._getCacheEntriesByPerson(nopriv).is_empty())
=== modified file 'lib/lp/security.py'
--- lib/lp/security.py 2013-04-09 11:51:24 +0000
+++ lib/lp/security.py 2013-05-02 17:02:45 +0000
@@ -998,13 +998,13 @@
# Grant visibility to people who can see branches owned by the
# private team.
team_branches = IBranchCollection(self.obj)
- if team_branches.visibleByUser(user.person).count() > 0:
+ if not team_branches.visibleByUser(user.person).is_empty():
return True
# Grant visibility to people who can see branches subscribed to
# by the private team.
team_branches = getUtility(IAllBranches).subscribedBy(self.obj)
- if team_branches.visibleByUser(user.person).count() > 0:
+ if not team_branches.visibleByUser(user.person).is_empty():
return True
# Grant visibility to branches visible to the user and which have
@@ -1012,7 +1012,7 @@
branches = getUtility(IAllBranches)
visible_branches = branches.visibleByUser(user.person)
mp = visible_branches.getMergeProposalsForReviewer(self.obj)
- if mp.count() > 0:
+ if not mp.is_empty():
return True
# Grant visibility to users in a team that has the private team as
=== modified file 'lib/lp/soyuz/adapters/archivedependencies.py'
--- lib/lp/soyuz/adapters/archivedependencies.py 2012-04-16 23:02:44 +0000
+++ lib/lp/soyuz/adapters/archivedependencies.py 2013-05-02 17:02:45 +0000
@@ -257,9 +257,7 @@
published_binaries = archive.getAllPublishedBinaries(
distroarchseries=distroarchseries,
status=PackagePublishingStatus.PUBLISHED)
- # XXX cprov 20080923 bug=246200: This count should be replaced
- # by bool() (__non_zero__) when storm implementation gets fixed.
- return published_binaries.count() > 0
+ return not published_binaries.is_empty()
def _get_binary_sources_list_line(archive, distroarchseries, pocket,
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2013-04-10 08:09:05 +0000
+++ lib/lp/soyuz/browser/archive.py 2013-05-02 17:02:45 +0000
@@ -866,9 +866,7 @@
This is after any filtering or overriding of the sources() method.
"""
- # Trying to use bool(self.filtered_sources) here resulted in bug
- # 702425 :(
- return self.filtered_sources.count() > 0
+ return not self.filtered_sources.is_empty()
class ArchiveView(ArchiveSourcePackageListViewBase):
@@ -1178,7 +1176,7 @@
to ensure that it only returns true if there are sources
that can be deleted in this archive.
"""
- return self.context.getSourcesForDeletion().count() > 0
+ return not self.context.getSourcesForDeletion().is_empty()
def validate_delete(self, action, data):
"""Validate deletion parameters.
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2013-05-01 04:08:37 +0000
+++ lib/lp/soyuz/model/archive.py 2013-05-02 17:02:45 +0000
@@ -242,11 +242,10 @@
# If the privacy is being changed ensure there are no sources
# published.
- sources_count = self.getPublishedSources().count()
- if sources_count > 0:
+ if not self.getPublishedSources().is_empty():
raise CannotSwitchPrivacy(
- "This archive has had %d sources published and therefore "
- "cannot have its privacy switched." % sources_count)
+ "This archive has had sources published and therefore "
+ "cannot have its privacy switched.")
return value
@@ -1818,7 +1817,7 @@
# Ensure there is not already a current subscription for subscriber:
subscriptions = getUtility(IArchiveSubscriberSet).getBySubscriber(
subscriber, archive=self)
- if subscriptions.count() > 0:
+ if not subscriptions.is_empty():
raise AlreadySubscribed(
"%s already has a current subscription for '%s'." % (
subscriber.displayname, self.displayname))
=== modified file 'lib/lp/soyuz/scripts/gina/library.py'
--- lib/lp/soyuz/scripts/gina/library.py 2011-12-22 05:37:22 +0000
+++ lib/lp/soyuz/scripts/gina/library.py 2013-05-02 17:02:45 +0000
@@ -51,5 +51,4 @@
digest = digester.hexdigest()
openfile.close()
librarian = getUtility(ILibraryFileAliasSet)
- return librarian.findBySHA1(digest).count() > 0
-
+ return not librarian.findBySHA1(digest).is_empty()
=== modified file 'lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py'
--- lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py 2012-01-19 03:09:38 +0000
+++ lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py 2013-05-02 17:02:45 +0000
@@ -141,8 +141,8 @@
self.getPublicationsForDistroseries())
# Assert that none of them is obsolete yet:
- self.assertTrue(published_sources.count() != 0)
- self.assertTrue(published_binaries.count() != 0)
+ self.assertFalse(published_sources.is_empty())
+ self.assertFalse(published_binaries.is_empty())
for source in published_sources:
self.assertTrue(
source.status == PackagePublishingStatus.PUBLISHED)
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2013-04-16 16:07:58 +0000
+++ lib/lp/testing/factory.py 2013-05-02 17:02:45 +0000
@@ -2553,7 +2553,7 @@
if parent_series is None:
dsp = getUtility(IDistroSeriesParentSet).getByDerivedSeries(
derived_series)
- if dsp.count() == 0:
+ if dsp.is_empty():
new_dsp = self.makeDistroSeriesParent(
derived_series=derived_series,
parent_series=parent_series)
@@ -3339,7 +3339,7 @@
`Message` table already.
"""
msg_id = make_msgid('launchpad')
- while Message.selectBy(rfc822msgid=msg_id).count() > 0:
+ while not Message.selectBy(rfc822msgid=msg_id).is_empty():
msg_id = make_msgid('launchpad')
return msg_id
=== modified file 'lib/lp/translations/model/potemplate.py'
--- lib/lp/translations/model/potemplate.py 2013-04-04 06:35:56 +0000
+++ lib/lp/translations/model/potemplate.py 2013-05-02 17:02:45 +0000
@@ -647,7 +647,7 @@
# current POTemplate be returned first.
orderBy=['(TranslationTemplateItem.POTemplate<>%s)' % (
sqlvalues(self))])[:2]
- if result.count() > 0:
+ if not result.is_empty():
return result[0]
else:
return None