Convert _findMember to use newly efficient isLPTeamMember, and remove name argument since we always just check launchpad.me anyway. Remove TeamNotFoundException which is now never thrown (false is just returned instead).

This commit is contained in:
Iain Lane 2009-05-17 16:06:26 +01:00
parent 95708ccc3b
commit d134469ed3
2 changed files with 5 additions and 12 deletions

View File

@ -22,7 +22,7 @@ import cookie
import urlopener as lp_urlopener
import urllib2
import sys
from udtexceptions import PackageNotFoundException, TeamNotFoundException, SeriesNotFoundException
from udtexceptions import PackageNotFoundException, SeriesNotFoundException
import libsupport as lp_libsupport
import launchpadlib
from re import findall
@ -114,12 +114,12 @@ def canUploadPackage(package, series=ubuntuDevelopmentSeries()):
for permission in uploaders:
current_uploader = permission.person
if _findMember(current_uploader, launchpad.me):
if _findMember(current_uploader):
return True
return False
def _findMember(haystack, needle):
def _findMember(haystack):
""" Find a person in a haystack. A haystack can consist of either people or teams.
If the needle is in the haystack: return True
@ -127,12 +127,9 @@ def _findMember(haystack, needle):
"""
if not haystack.is_team:
return (str(haystack) == str(needle))
return (str(haystack) == str(launchpad.me))
elif haystack.is_valid: # is a team
members = haystack.members
for m in members:
if _findMember(m, needle):
return True
return isLPTeamMember(haystack.name)
return False

View File

@ -2,10 +2,6 @@ class PackageNotFoundException(BaseException):
""" Thrown when a package is not found """
pass
class TeamNotFoundException(BaseException):
""" Thrown when a team is not found """
pass
class SeriesNotFoundException(BaseException):
""" Thrown when a distroseries is not found """
pass