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

View File

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