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) 31WIN81 = OSVersion('win8.1', 6.3) 32WIN10 = OSVersion('win10', 10) 33 34LEOPARD = OSVersion('leopard', 105) 35SNOWLEOPARD = OSVersion('snowleopard', 106) 36LION = OSVersion('lion', 107) 37MOUNTAINLION = OSVersion('mountainlion', 108) 38MAVERICKS = OSVersion('mavericks', 109) 39YOSEMITE = OSVersion('yosemite', 1010) 40ELCAPITAN = OSVersion('elcapitan', 1011) 41