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 8 class 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 27 XP = OSVersion('xp', 5.1) 28 VISTA = OSVersion('vista', 6.0) 29 WIN7 = OSVersion('win7', 6.1) 30 WIN8 = OSVersion('win8', 6.2) 31 WIN81 = OSVersion('win8.1', 6.3) 32 WIN10 = OSVersion('win10', 10) 33 34 LEOPARD = OSVersion('leopard', 105) 35 SNOWLEOPARD = OSVersion('snowleopard', 106) 36 LION = OSVersion('lion', 107) 37 MOUNTAINLION = OSVersion('mountainlion', 108) 38 MAVERICKS = OSVersion('mavericks', 109) 39 YOSEMITE = OSVersion('yosemite', 1010) 40 ELCAPITAN = OSVersion('elcapitan', 1011) 41