diff options
author | Steve Langasek <steve.langasek@ubuntu.com> | 2012-02-21 16:49:04 +0100 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2012-02-27 13:32:39 +0100 |
commit | 5fd0f7b40830f236b07519818bc525b9d530d9d8 (patch) | |
tree | 1868c1370266c334b4c00df37451db4a622c9783 /lsb_release.py | |
parent | 6d330a825c24be97ab0df9c0826fe4681d1c58d1 (diff) |
Don't run apt-cache if /etc/lsb-release exists.
Since /etc/lsb-release overrides detected information, there's no
need to try and detect that information if lsb-release contains
everything we need. This saves us calling the hugely expensive
apt-cache.
Diffstat (limited to 'lsb_release.py')
-rw-r--r-- | lsb_release.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lsb_release.py b/lsb_release.py index 5c6cb9a..9208858 100644 --- a/lsb_release.py +++ b/lsb_release.py @@ -284,9 +284,15 @@ def get_lsb_information(): return distinfo def get_distro_information(): - distinfo = guess_debian_release() - distinfo.update(get_lsb_information()) - return distinfo + lsbinfo = get_lsb_information() + # OS is only used inside guess_debian_release anyway + for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): + if key not in lsbinfo: + distinfo = guess_debian_release() + distinfo.update(lsbinfo) + return distinfo + else: + return lsbinfo def test(): print get_distro_information() |