* ubuntutools/lp/lpapicache.py, ubuntutools/lp/libsupport.py: Add support

for different LP API versions.
* ubuntutools/lp/__init__.py: Set the '1.0' LP API version as default.
* massfile: Updated to 1.0 LP API.
This commit is contained in:
Michael Bienia 2010-03-20 18:27:31 +01:00
parent c921eaf947
commit e4e8f156bd
5 changed files with 25 additions and 19 deletions

6
debian/changelog vendored
View File

@ -3,8 +3,12 @@ ubuntu-dev-tools (0.97) UNRELEASED; urgency=low
[ Michael Bienia ]
* lp-shell: Support all to the launchpadlib Python module known service
names.
* ubuntutools/lp/lpapicache.py, ubuntutools/lp/libsupport.py: Add support
for different LP API versions.
* ubuntutools/lp/__init__.py: Set the '1.0' LP API version as default.
* massfile: Updated to 1.0 LP API.
-- Michael Bienia <geser@ubuntu.com> Thu, 18 Mar 2010 11:01:21 +0100
-- Michael Bienia <geser@ubuntu.com> Sat, 20 Mar 2010 18:26:49 +0100
ubuntu-dev-tools (0.96) lucid; urgency=low

View File

@ -106,12 +106,13 @@ def file_bug(config):
status = config["status"].capitalize()
else:
status = "Confirmed"
task.transitionToStatus(status=status)
task.status = status
assignee = config["assignee"]
if assignee:
assignee_url = "%s~%s" %(launchpad._root_uri, assignee)
bug.transitionToAssignee(assignee=assignee_url)
task.assignee = assignee_url
task.lp_save()
except:
"Bug for '%s' was not filed." % config["sourcepackage"]

View File

@ -3,3 +3,4 @@
##
service = 'edge'
api_version = '1.0'

View File

@ -37,7 +37,7 @@ except:
Credentials = None
Launchpad = None
from ubuntutools.lp import service
from ubuntutools.lp import (service, api_version)
def find_credentials(consumer, files, level=None):
""" search for credentials matching 'consumer' in path for given access level. """
@ -79,7 +79,7 @@ def get_launchpad(consumer, server=service, cache=None,
cred_file=None, level=None):
credentials = get_credentials(consumer, cred_file, level)
cache = cache or os.environ.get("LPCACHE", None)
return Launchpad(credentials, server, cache)
return Launchpad(credentials, server, cache, version=api_version)
def query_to_dict(query_string):
result = dict()
@ -106,7 +106,7 @@ def translate_web_api(url, launchpad):
return url
def translate_api_web(self_url):
return self_url.replace("api.", "").replace("beta/", "")
return self_url.replace("api.", "").replace("%s/" % (api_version), "")
LEVEL = {
0: "UNAUTHORIZED",

View File

@ -32,7 +32,7 @@ from launchpadlib.uris import lookup_service_root
from lazr.restfulclient.resource import Entry
import ubuntutools.lp.libsupport as libsupport
from ubuntutools.lp import service
from ubuntutools.lp import (service, api_version)
from ubuntutools.lp.udtexceptions import *
__all__ = [
@ -96,7 +96,7 @@ class BaseWrapper(object):
resource_type = None # it's a base class after all
def __new__(cls, data):
if isinstance(data, basestring) and data.startswith(lookup_service_root(service) + 'beta/'):
if isinstance(data, basestring) and data.startswith('%s%s/' % (lookup_service_root(service), api_version)):
# looks like a LP API URL
# check if it's already cached
cached = cls._cache.get(data)
@ -151,7 +151,7 @@ class Distribution(BaseWrapper):
'''
Wrapper class around a LP distribution object.
'''
resource_type = lookup_service_root(service) + 'beta/#distribution'
resource_type = lookup_service_root(service) + api_version + '/#distribution'
def __init__(self, *args):
# Don't share _series and _archives between different Distributions
@ -214,7 +214,7 @@ class Distribution(BaseWrapper):
self._series[series.name] = series
self._series[series.version] = series
except HTTPError:
raise SeriesNotFoundException("Error: Release '%s' is unknown in '%s'." % (name_or_version, self.display_name))
raise SeriesNotFoundException("Release '%s' is unknown in '%s'." % (name_or_version, self.display_name))
return self._series[name_or_version]
def getDevelopmentSeries(self):
@ -233,14 +233,14 @@ class DistroSeries(BaseWrapper):
'''
Wrapper class around a LP distro series object.
'''
resource_type = lookup_service_root(service) + 'beta/#distro_series'
resource_type = lookup_service_root(service) + api_version + '/#distro_series'
class Archive(BaseWrapper):
'''
Wrapper class around a LP archive object.
'''
resource_type = lookup_service_root(service) + 'beta/#archive'
resource_type = lookup_service_root(service) + api_version + '/#archive'
def __init__(self, *args):
# Don't share _srcpkgs between different Archives
@ -301,7 +301,7 @@ class SourcePackagePublishingHistory(BaseWrapper):
'''
Wrapper class around a LP source package object.
'''
resource_type = lookup_service_root(service) + 'beta/#source_package_publishing_history'
resource_type = lookup_service_root(service) + api_version + '/#source_package_publishing_history'
def __init__(self, *args):
# Don't share _builds between different SourcePackagePublishingHistory objects
@ -402,8 +402,8 @@ class PersonTeam(BaseWrapper):
__metaclass__ = MetaPersonTeam
resource_type = (
lookup_service_root(service) + 'beta/#person',
lookup_service_root(service) + 'beta/#team',
lookup_service_root(service) + api_version + '/#person',
lookup_service_root(service) + api_version + '/#team',
)
def __init__(self, *args):
@ -493,7 +493,7 @@ class Build(BaseWrapper):
'''
Wrapper class around a build object.
'''
resource_type = lookup_service_root(service) + 'beta/#build'
resource_type = lookup_service_root(service) + api_version + '/#build'
def __str__(self):
return u'%s: %s' % (self.arch_tag, self.buildstate)
@ -515,4 +515,4 @@ class DistributionSourcePackage(BaseWrapper):
'''
Caching class for distribution_source_package objects.
'''
resource_type = lookup_service_root(service) + 'beta/#distribution_source_package'
resource_type = lookup_service_root(service) + api_version + '/#distribution_source_package'