-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathversion_helpers.py
More file actions
42 lines (37 loc) · 1.7 KB
/
Copy pathversion_helpers.py
File metadata and controls
42 lines (37 loc) · 1.7 KB
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
__all__ = [
"WindowsVersionHelpers"
]
class WindowsVersionHelpers:
@staticmethod
def is_windows_version_or_greater(windows_version, major: int, minor: int, build: int) -> bool:
"""
Parameters:
windows_version: An object from getwindowsversion.
major (int): The minimum major OS version number.
minor (int): The minimum minor OS version number.
build (int): The minimum build version number.
Returns:
True if the specified version matches or if it is greater than the version of the current Windows OS. Otherwise, False.
"""
if windows_version.major > major:
return True
elif windows_version.major == major and windows_version.minor > minor:
return True
else:
return (
windows_version.major == major
and windows_version.minor == minor
and windows_version.build >= build
)
@staticmethod
def is_windows_vista_sp2_or_greater(windows_version) -> bool:
# From https://www.lifewire.com/windows-version-numbers-2625171
return WindowsVersionHelpers.is_windows_version_or_greater(windows_version, 6, 0, 6002)
@staticmethod
def is_windows_8_1_or_greater(windows_version) -> bool:
# From https://www.lifewire.com/windows-version-numbers-2625171
return WindowsVersionHelpers.is_windows_version_or_greater(windows_version, 6, 0, 9200)
@staticmethod
def is_windows_10_or_greater(windows_version) -> bool:
# From https://www.lifewire.com/windows-version-numbers-2625171
return WindowsVersionHelpers.is_windows_version_or_greater(windows_version, 10, 0, 10240)