1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# pylint: disable=protected-access
6
7
8class OSVersion(str):
9  def __new__(cls, friendly_name, sortable_name):
10    version = str.__new__(cls, friendly_name)
11    version._sortable_name = sortable_name
12    return version
13
14  def __lt__(self, other):
15    return self._sortable_name < other._sortable_name
16
17  def __gt__(self, other):
18    return self._sortable_name > other._sortable_name
19
20  def __le__(self, other):
21    return self._sortable_name <= other._sortable_name
22
23  def __ge__(self, other):
24    return self._sortable_name >= other._sortable_name
25
26
27XP = OSVersion('xp', 5.1)
28VISTA = OSVersion('vista', 6.0)
29WIN7 = OSVersion('win7', 6.1)
30WIN8 = OSVersion('win8', 6.2)
31WIN10 = OSVersion('win10', 10)
32
33LEOPARD = OSVersion('leopard', 105)
34SNOWLEOPARD = OSVersion('snowleopard', 106)
35LION = OSVersion('lion', 107)
36MOUNTAINLION = OSVersion('mountainlion', 108)
37MAVERICKS = OSVersion('mavericks', 109)
38YOSEMITE = OSVersion('yosemite', 1010)
39ELCAPITAN = OSVersion('elcapitan', 1011)
40