Package: python-distro-info
Version: 0.4~oneiric1~ppa1
Severity: wishlist
Tags: patch
Distro info allows you to get the release version number by passing the "--
release" flag:
$ distro-info --stable --release
11.10
It would be nice to access the same info easily from python-distro-info. For
instance, something like:
>>> from distro_info import UbuntuDistroInfo
>>> UbuntuDistroInfo().stable()
'oneiric'
>>> UbuntuDistroInfo().stable("version")
'11.10'
Attached patch is not really complete. I'm hoping for some review/feedback
before proceeding further.
Thanks!
-- Andrew Starr-Bochicchio
Ubuntu Developer <https://launchpad.net/~andrewsomething>
Debian Maintainer
<http://qa.debian.org/developer.php?login=a.starr.b%40gmail.com>
PGP/GPG Key ID: D53FDCB1
-- System Information:
Debian Release: wheezy/sid
APT prefers oneiric-updates
APT policy: (500, 'oneiric-updates'), (500, 'oneiric-security'), (500,
'oneiric'), (100, 'oneiric-backports')
Architecture: i386 (i686)
Kernel: Linux 3.0.0-12-generic (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-distro-info depends on:
ii distro-info-data 0.4~oneiric1~ppa1 information about the distribution
ii python 2.7.2-7ubuntu2 interactive high-level object-orie
ii python2.6 2.6.7-4ubuntu1 An interactive high-level object-o
ii python2.7 2.7.2-5ubuntu1 An interactive high-level object-o
python-distro-info recommends no packages.
python-distro-info suggests no packages.
-- no debconf information
diff --git a/python/distro_info.py b/python/distro_info.py
index 743ae20..f10bbf8 100644
--- a/python/distro_info.py
+++ b/python/distro_info.py
@@ -71,9 +71,14 @@ class DistroInfo(object):
self._date = datetime.date.today()
@property
- def all(self):
- """List all known distributions."""
- return [x["series"] for x in self._rows]
+ def all(self, result="series"):
+ """List all known distribution codenames."""
+ return [x[result] for x in self._rows]
+
+ @property
+ def all_releases(self, result="version"):
+ """List all known distribution releases."""
+ return [x[result] for x in self._rows]
def _avail(self, date):
"""Return all distributions that were available on the given date."""
@@ -83,7 +88,7 @@ class DistroInfo(object):
"""Map codename aliases to the codename they describe."""
return release
- def devel(self, date=None):
+ def devel(self, result="series", date=None):
"""Get latest development distribution based on the given date."""
if date is None:
date = self._date
@@ -93,9 +98,9 @@ class DistroInfo(object):
(x["eol"] is None or date <= x["eol"]))]
if not distros:
raise DistroDataOutdated()
- return distros[-1]["series"]
+ return distros[-1][result]
- def stable(self, date=None):
+ def stable(self, result="series", date=None):
"""Get latest stable distribution based on the given date."""
if date is None:
date = self._date
@@ -104,7 +109,7 @@ class DistroInfo(object):
(x["eol"] is None or date <= x["eol"])]
if not distros:
raise DistroDataOutdated()
- return distros[-1]["series"]
+ return distros[-1][result]
def supported(self, date=None):
"""Get list of all supported distributions based on the given date."""
@@ -114,13 +119,13 @@ class DistroInfo(object):
"""Check if the given codename is known."""
return codename in self.all
- def unsupported(self, date=None):
+ def unsupported(self, result="series", date=None):
"""Get list of all unsupported distributions based on the given date."""
if date is None:
date = self._date
supported = self.supported(date)
- distros = [x["series"] for x in self._avail(date)
- if x["series"] not in supported]
+ distros = [x[result] for x in self._avail(date)
+ if x[result] not in supported]
return distros
@@ -144,7 +149,7 @@ class DebianDistroInfo(DistroInfo):
codename = default
return codename
- def devel(self, date=None):
+ def devel(self, result="series", date=None):
"""Get latest development distribution based on the given date."""
if date is None:
date = self._date
@@ -154,9 +159,9 @@ class DebianDistroInfo(DistroInfo):
(x["eol"] is None or date <= x["eol"]))]
if len(distros) < 2:
raise DistroDataOutdated()
- return distros[-2]["series"]
+ return distros[-2][result]
- def old(self, date=None):
+ def old(self, result="series", date=None):
"""Get old (stable) Debian distribution based on the given date."""
if date is None:
date = self._date
@@ -164,18 +169,18 @@ class DebianDistroInfo(DistroInfo):
if x["release"] is not None and date >= x["release"]]
if len(distros) < 2:
raise DistroDataOutdated()
- return distros[-2]["series"]
+ return distros[-2][result]
- def supported(self, date=None):
+ def supported(self, result="series", date=None):
"""Get list of all supported Debian distributions based on the given
date."""
if date is None:
date = self._date
- distros = [x["series"] for x in self._avail(date)
+ distros = [x[result] for x in self._avail(date)
if x["eol"] is None or date <= x["eol"]]
return distros
- def testing(self, date=None):
+ def testing(self, result="series", date=None):
"""Get latest testing Debian distribution based on the given date."""
if date is None:
date = self._date
@@ -185,7 +190,7 @@ class DebianDistroInfo(DistroInfo):
(x["eol"] is None or date <= x["eol"]))]
if not distros:
raise DistroDataOutdated()
- return distros[-1]["series"]
+ return distros[-1][result]
def valid(self, codename):
"""Check if the given codename is known."""
@@ -199,7 +204,7 @@ class UbuntuDistroInfo(DistroInfo):
def __init__(self):
super(UbuntuDistroInfo, self).__init__("ubuntu")
- def lts(self, date=None):
+ def lts(self, result="series", date=None):
"""Get latest long term support (LTS) Ubuntu distribution based on the
given date."""
if date is None:
@@ -209,7 +214,7 @@ class UbuntuDistroInfo(DistroInfo):
date <= x["eol"]]
if not distros:
raise DistroDataOutdated()
- return distros[-1]["series"]
+ return distros[-1][result]
def is_lts(self, codename):
"""Is codename an LTS release?"""
@@ -218,12 +223,12 @@ class UbuntuDistroInfo(DistroInfo):
return False
return "LTS" in distros[0]["version"]
- def supported(self, date=None):
+ def supported(self, result="series", date=None):
"""Get list of all supported Ubuntu distributions based on the given
date."""
if date is None:
date = self._date
- distros = [x["series"] for x in self._avail(date)
+ distros = [x[result] for x in self._avail(date)
if date <= x["eol"] or
(x["eol-server"] is not None and date <= x["eol-server"])]
return distros