diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-11-10 10:41:45 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-11-10 10:41:45 +0100 |
| commit | b4fac97986469c356a3b1030c14d600ba333202e (patch) | |
| tree | 5bab0ea87b8e61833305e4341e5b3d7721e09bc9 /aptsources | |
| parent | 46abf8f70e4ec1c520cd2bcf1a9493f2869193a1 (diff) | |
| download | python-apt-b4fac97986469c356a3b1030c14d600ba333202e.tar.gz | |
* aptsources/distro.py:
- add parameter to get_distro() to make unit testing easier
* tests/test_aptsources_ports.py:
- add test for arch specific handling (when sub arch is on
a different mirror than "main" arches)
Diffstat (limited to 'aptsources')
| -rw-r--r-- | aptsources/distro.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/aptsources/distro.py b/aptsources/distro.py index 6d3b453f..f271bbc4 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -414,15 +414,22 @@ class UbuntuDistribution(Distribution): Distribution.get_mirrors(self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") -def get_distro(): - ''' Check the currently used distribution and return the corresponding - distriubtion class that supports distro specific features. ''' - lsb_info = [] - for lsb_option in ["-i", "-c", "-d", "-r"]: +def get_distro(id=None,codename=None,description=None,release=None): + """ + Check the currently used distribution and return the corresponding + distriubtion class that supports distro specific features. + + If no paramter are given the distro will be auto detected via + a call to lsb-release + """ + # make testing easier + if not (id and codename and description and release): + lsb_info = [] + for lsb_option in ["-i", "-c", "-d", "-r"]: pipe = os.popen("lsb_release %s -s" % lsb_option) lsb_info.append(pipe.read().strip()) del pipe - (id, codename, description, release) = lsb_info + (id, codename, description, release) = lsb_info if id == "Ubuntu": return UbuntuDistribution(id, codename, description, release) |
