summaryrefslogtreecommitdiff
path: root/libka/ubuntu_info.py
blob: 537ff03d459ee2df5ef0e71fab77df9c5eb9f602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space modified;
# vim: expandtab ts=4

############################################################################
#   Copyright © 2016 José Manuel Santamaría Lema <panfaust@gmail.com>      #
#                                                                          #
#   This program is free software; you can redistribute it and/or modify   #
#   it under the terms of the GNU General Public License as published by   #
#   the Free Software Foundation; either version 2 of the License, or      #
#   (at your option) any later version.                                    #
############################################################################

import sys

this = sys.modules[__name__]

this._ubuntu_version_map = {
    "bionic": "18.04",
    "artful": "17.10",
    "zesty": "17.04",
    "yakkety": "16.10",
    "xenial": "16.04",
    "wily": "15.10",
    "vivid": "15.04"
}

this._ubuntu_name_map = dict((v, k) for k, v in _ubuntu_version_map.items())

def ubuntuDistVersionFromName(dist_name):
    return _ubuntu_version_map[dist_name]

def ubuntuDistNameFromVersion(version):
    return _ubuntu_name_map[version]

def previousUbuntuVersion(version):
    year,month = version.split('.')
    if month == '10':
        month = '04'
    else:
        year = int(year) - 1
        month = '10'
    version = year + '.' + month
    return version