Skip to content

Commit

Permalink
Fall back on NAME if no PRETTY_NAME is given
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed Jul 2, 2019
1 parent a83a219 commit 88f5433
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions qutebrowser/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def distribution():
except (OSError, UnicodeDecodeError):
return None

pretty = info.get('PRETTY_NAME', 'Unknown')
if pretty == 'Linux': # Thanks, Funtoo
pretty = info.get('NAME', pretty)
pretty = info.get('PRETTY_NAME', None)
if pretty in ['Linux', None]: # Funtoo has PRETTY_NAME=Linux
pretty = info.get('NAME', 'Unknown')

if 'VERSION_ID' in info:
dist_version = pkg_resources.parse_version(info['VERSION_ID'])
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/utils/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,15 @@
version.DistributionInfo(
id='org.kde.Platform', parsed=version.Distribution.kde,
version=pkg_resources.parse_version('5.12'),
pretty='Unknown')),
pretty='KDE')),
# No PRETTY_NAME
("""
NAME="Tux"
ID=tux
""",
version.DistributionInfo(
id='tux', parsed=version.Distribution.unknown,
version=None, pretty='Tux')),
])
def test_distribution(tmpdir, monkeypatch, os_release, expected):
os_release_file = tmpdir / 'os-release'
Expand Down

0 comments on commit 88f5433

Please sign in to comment.