mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
ubuntutools.distro_info: Add a function to find the distribution that
used a given release codename.
This commit is contained in:
parent
2398d09ba4
commit
2560aa210b
4
debian/changelog
vendored
4
debian/changelog
vendored
@ -26,8 +26,10 @@ ubuntu-dev-tools (0.125) UNRELEASED; urgency=low
|
|||||||
* ubuntutools.misc: Add a new "system_distribution_chain", which returns
|
* ubuntutools.misc: Add a new "system_distribution_chain", which returns
|
||||||
a list starting with the current distribution and working its way up
|
a list starting with the current distribution and working its way up
|
||||||
each distribution's parent.
|
each distribution's parent.
|
||||||
|
* ubuntutools.distro_info: Add a function to find the distribution that
|
||||||
|
used a given release codename.
|
||||||
|
|
||||||
-- Evan Broder <evan@ebroder.net> Sat, 11 Jun 2011 05:05:21 -0700
|
-- Evan Broder <evan@ebroder.net> Sat, 11 Jun 2011 05:06:44 -0700
|
||||||
|
|
||||||
ubuntu-dev-tools (0.124) unstable; urgency=low
|
ubuntu-dev-tools (0.124) unstable; urgency=low
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ import csv
|
|||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from ubuntutools.misc import system_distribution_chain
|
||||||
|
|
||||||
def convert_date(string):
|
def convert_date(string):
|
||||||
"""Convert a date string in ISO 8601 into a datetime object."""
|
"""Convert a date string in ISO 8601 into a datetime object."""
|
||||||
if not string:
|
if not string:
|
||||||
@ -195,3 +197,29 @@ class UbuntuDistroInfo(DistroInfo):
|
|||||||
if date <= x["eol"] or
|
if date <= x["eol"] or
|
||||||
(x["eol-server"] is not None and date <= x["eol-server"])]
|
(x["eol-server"] is not None and date <= x["eol-server"])]
|
||||||
return distros
|
return distros
|
||||||
|
|
||||||
|
_vendor_to_distroinfo = {"Debian": DebianDistroInfo,
|
||||||
|
"Ubuntu": UbuntuDistroInfo}
|
||||||
|
def vendor_to_distroinfo(vendor):
|
||||||
|
""" vendor_to_distroinfo(string) -> DistroInfo class
|
||||||
|
|
||||||
|
Convert a string name of a distribution into a DistroInfo subclass
|
||||||
|
representing that distribution, or None if the distribution is
|
||||||
|
unknown.
|
||||||
|
"""
|
||||||
|
return _vendor_to_distroinfo.get(vendor)
|
||||||
|
|
||||||
|
def codename_to_distribution(codename):
|
||||||
|
""" codename_to_distribution(string) -> string
|
||||||
|
|
||||||
|
Finds a given release codename in your distribution's genaology
|
||||||
|
(i.e. looking at the current distribution and its parents), or
|
||||||
|
print an error message and return None if it can't be found
|
||||||
|
"""
|
||||||
|
for distro in system_distribution_chain():
|
||||||
|
info = vendor_to_distroinfo(distro)
|
||||||
|
if not info:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if codename in info().all:
|
||||||
|
return distro
|
||||||
|
Loading…
x
Reference in New Issue
Block a user