mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-19 04:41:28 +00:00
* lpapiwrapper.py:
Move getUbuntu{Development,}Series from LpApiWrapper to Distribution and rename it to get{Development,}Series * pull-lp-source, requestsync: Updated for the above mention change.
This commit is contained in:
parent
30915541e4
commit
fcf86d2ad2
@ -76,7 +76,7 @@ if __name__ == '__main__':
|
|||||||
if len(args) == 2: # Custom distribution specified.
|
if len(args) == 2: # Custom distribution specified.
|
||||||
release = str(args[1]).lower()
|
release = str(args[1]).lower()
|
||||||
else:
|
else:
|
||||||
release = os.getenv('DIST') or LpApiWrapper.getUbuntuDevelopmentSeries().name
|
release = os.getenv('DIST') or LpApiWrapper.getUbuntuDistribution().getDevelopmentSeries().name
|
||||||
|
|
||||||
# Arguments are correct, proceed.
|
# Arguments are correct, proceed.
|
||||||
# Check that the Ubuntu release and package specified exists.
|
# Check that the Ubuntu release and package specified exists.
|
||||||
|
@ -474,7 +474,7 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(args) not in (2, 3): # no release specified, assume development release
|
if len(args) not in (2, 3): # no release specified, assume development release
|
||||||
release = LpApiWrapper.getUbuntuDevelopmentSeries().name
|
release = LpApiWrapper.getUbuntuDistribution().getDevelopmentSeries().name
|
||||||
print >> sys.stderr, ("Source package / target release missing - assuming %s " %
|
print >> sys.stderr, ("Source package / target release missing - assuming %s " %
|
||||||
release)
|
release)
|
||||||
else:
|
else:
|
||||||
|
@ -57,17 +57,11 @@ class LpApiWrapper(object):
|
|||||||
Wrapper around some common used LP API functions used in
|
Wrapper around some common used LP API functions used in
|
||||||
ubuntu-dev-tools.
|
ubuntu-dev-tools.
|
||||||
'''
|
'''
|
||||||
_archive = None
|
|
||||||
_devel_series = None
|
|
||||||
_me = None
|
_me = None
|
||||||
_series = dict()
|
|
||||||
_src_pkg = dict()
|
_src_pkg = dict()
|
||||||
_upload_comp = dict()
|
_upload_comp = dict()
|
||||||
_upload_pkg = dict()
|
_upload_pkg = dict()
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getMe(cls):
|
def getMe(cls):
|
||||||
'''
|
'''
|
||||||
@ -84,42 +78,6 @@ class LpApiWrapper(object):
|
|||||||
'''
|
'''
|
||||||
return Distribution('ubuntu')
|
return Distribution('ubuntu')
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def getUbuntuSeries(cls, name_or_version):
|
|
||||||
'''
|
|
||||||
Returns the LP representation of a series passed by name (e.g.
|
|
||||||
'karmic') or version (e.g. '9.10').
|
|
||||||
If the series is not found: raise SeriesNotFoundException
|
|
||||||
'''
|
|
||||||
name_or_version = str(name_or_version)
|
|
||||||
if name_or_version not in cls._series:
|
|
||||||
try:
|
|
||||||
series = cls.getUbuntuDistribution().getSeries(name_or_version = name_or_version)
|
|
||||||
# Cache with name and version
|
|
||||||
cls._series[series.name] = DistroSeries(series)
|
|
||||||
cls._series[series.version] = DistroSeries(series)
|
|
||||||
except HTTPError:
|
|
||||||
raise SeriesNotFoundException("Error: Unknown Ubuntu release: '%s'." % name_or_version)
|
|
||||||
|
|
||||||
return cls._series[name_or_version]
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def getUbuntuDevelopmentSeries(cls):
|
|
||||||
'''
|
|
||||||
Returns the LP representation of the current development series of
|
|
||||||
Ubuntu.
|
|
||||||
'''
|
|
||||||
|
|
||||||
if not cls._devel_series:
|
|
||||||
dev = cls.getUbuntuDistribution().current_series
|
|
||||||
cls._devel_series = DistroSeries(dev)
|
|
||||||
# Cache it in _series if not already done
|
|
||||||
if dev.name not in cls._series:
|
|
||||||
cls._series[dev.name] = cls._devel_series
|
|
||||||
cls._series[dev.version] = cls._devel_series
|
|
||||||
|
|
||||||
return cls._devel_series
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getUbuntuSourcePackage(cls, name, series, pocket = 'Release'):
|
def getUbuntuSourcePackage(cls, name, series, pocket = 'Release'):
|
||||||
'''
|
'''
|
||||||
@ -135,12 +93,12 @@ class LpApiWrapper(object):
|
|||||||
|
|
||||||
# Check if we have already a LP representation of an Ubuntu series or not
|
# Check if we have already a LP representation of an Ubuntu series or not
|
||||||
if not isinstance(series, DistroSeries):
|
if not isinstance(series, DistroSeries):
|
||||||
series = cls.getUbuntuSeries(str(series))
|
series = cls.getUbuntuDistribution().getSeries(series)
|
||||||
|
|
||||||
if (name, series, pocket) not in cls._src_pkg:
|
if (name, series, pocket) not in cls._src_pkg:
|
||||||
try:
|
try:
|
||||||
srcpkg = cls.getUbuntuDistribution().getMainArchive().getPublishedSources(
|
srcpkg = cls.getUbuntuDistribution().getMainArchive().getPublishedSources(
|
||||||
source_name = name, distro_series = series._lpobject, pocket = pocket,
|
source_name = name, distro_series = series(), pocket = pocket,
|
||||||
status = 'Published', exact_match = True)[0]
|
status = 'Published', exact_match = True)[0]
|
||||||
cls._src_pkg[(name, series, pocket)] = SourcePackage(srcpkg)
|
cls._src_pkg[(name, series, pocket)] = SourcePackage(srcpkg)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@ -173,7 +131,7 @@ class LpApiWrapper(object):
|
|||||||
else:
|
else:
|
||||||
if not series:
|
if not series:
|
||||||
# Fall-back to current Ubuntu development series
|
# Fall-back to current Ubuntu development series
|
||||||
series = cls.getUbuntuDevelopmentSeries()
|
series = cls.getUbuntuDistribution().getDevelopmentSeries()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
component = cls.getUbuntuSourcePackage(package, series).getComponent()
|
component = cls.getUbuntuSourcePackage(package, series).getComponent()
|
||||||
@ -284,6 +242,11 @@ class Distribution(BaseWrapper):
|
|||||||
'''
|
'''
|
||||||
resource_type = 'https://api.edge.launchpad.net/beta/#distribution'
|
resource_type = 'https://api.edge.launchpad.net/beta/#distribution'
|
||||||
|
|
||||||
|
def __init__(self, *args):
|
||||||
|
# Don't share _series between different Distributions
|
||||||
|
if '_series' not in self.__dict__:
|
||||||
|
self._series = dict()
|
||||||
|
|
||||||
def cache(self):
|
def cache(self):
|
||||||
self._cache[self.name] = self
|
self._cache[self.name] = self
|
||||||
|
|
||||||
@ -307,6 +270,33 @@ class Distribution(BaseWrapper):
|
|||||||
self._archive = self.main_archive
|
self._archive = self.main_archive
|
||||||
return self._archive
|
return self._archive
|
||||||
|
|
||||||
|
def getSeries(self, name_or_version):
|
||||||
|
'''
|
||||||
|
Returns a DistroSeries object for a series passed by name
|
||||||
|
(e.g. 'karmic') or version (e.g. '9.10').
|
||||||
|
If the series is not found: raise SeriesNotFoundException
|
||||||
|
'''
|
||||||
|
if name_or_version not in self._series:
|
||||||
|
try:
|
||||||
|
series = DistroSeries(self().getSeries(name_or_version = name_or_version))
|
||||||
|
# Cache with name and version
|
||||||
|
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))
|
||||||
|
return self._series[name_or_version]
|
||||||
|
|
||||||
|
def getDevelopmentSeries(self):
|
||||||
|
'''
|
||||||
|
Returns a DistroSeries object of the current development series.
|
||||||
|
'''
|
||||||
|
dev = DistroSeries(self.current_series_link)
|
||||||
|
# Cache it in _series if not already done
|
||||||
|
if dev.name not in self._series:
|
||||||
|
self._series[dev.name] = dev
|
||||||
|
self._series[dev.version] = dev
|
||||||
|
return dev
|
||||||
|
|
||||||
|
|
||||||
class DistroSeries(BaseWrapper):
|
class DistroSeries(BaseWrapper):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user