-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add add DIST_CODENAME with --load-distribution-infos
- Loading branch information
1 parent
72a88a8
commit 63ce9b4
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class DistroInfo: | ||
_id = '' | ||
_name = '' | ||
_version = '' | ||
_codename = '' | ||
|
||
def __init__(self): | ||
with open('/etc/os-release') as f: | ||
s = f.read() | ||
patt = r'(?:^|\n)(NAME|VERSION_CODENAME|ID|VERSION_ID)="?([^\n"]+)' | ||
for m in re.finditer(patt, s): | ||
k = m.group(1) | ||
v = m.group(2) | ||
if k == 'NAME': | ||
self._name = v | ||
elif k == 'ID': | ||
self._id = v | ||
elif k == 'VERSION_ID': | ||
self._version = v | ||
elif k == 'VERSION_CODENAME': | ||
self._codename = v | ||
|
||
def id(self) -> str: | ||
return self._id | ||
|
||
def name(self) -> str: | ||
return self._name | ||
|
||
def version(self) -> str: | ||
return self._version | ||
|
||
def codename(self) -> str: | ||
return self._codename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters