-
-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
winVersion.isWin10: accept both int and str for Windows 10 version parameter #11796
Changes from all commits
bd512a7
d7d97f0
23b86da
64fdf5f
28c25c7
24632d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
# A part of NonVisual Desktop Access (NVDA) | ||
# Copyright (C) 2006-2020 NV Access Limited | ||
# Copyright (C) 2006-2020 NV Access Limited, Bill Dengler, Joseph Lee | ||
# This file is covered by the GNU General Public License. | ||
# See the file COPYING for more details. | ||
|
||
import sys | ||
import os | ||
from typing import Union | ||
import winUser | ||
|
||
winVersion=sys.getwindowsversion() | ||
|
@@ -28,36 +29,40 @@ def isUwpOcrAvailable(): | |
|
||
|
||
WIN10_VERSIONS_TO_BUILDS = { | ||
1507: 10240, | ||
1511: 10586, | ||
1607: 14393, | ||
1703: 15063, | ||
1709: 16299, | ||
1803: 17134, | ||
1809: 17763, | ||
1903: 18362, | ||
1909: 18363, | ||
2004: 19041, | ||
2009: 19042, | ||
"1507": 10240, | ||
"1511": 10586, | ||
"1607": 14393, | ||
"1703": 15063, | ||
"1709": 16299, | ||
"1803": 17134, | ||
"1809": 17763, | ||
"1903": 18362, | ||
"1909": 18363, | ||
"2004": 19041, | ||
"20H2": 19042, | ||
} | ||
|
||
|
||
def isWin10(version: int = 1507, atLeast: bool = True): | ||
def isWin10(version: Union[int, str] = 1507, atLeast: bool = True): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could become a mistake from and API sense. This will result in a very hard to untangle confusion between version and build. It's also not clear on first glance (without reading the docs / implementation) that this function tells you if the OS is a particular version or greater or if it tells you that the versions string is a valid one for Windows 10. To fix this it might be helpful to keep but deprecate the Another alternative, would be a new
|
||
""" | ||
Returns True if NVDA is running on the supplied release version of Windows 10. If no argument is supplied, returns True for all public Windows 10 releases. | ||
@param version: a release version of Windows 10 (such as 1903). | ||
@param atLeast: return True if NVDA is running on at least this Windows 10 build (i.e. this version or higher). | ||
""" | ||
if winVersion.major != 10: | ||
return False | ||
# #11795: October 2020 Update is actually 20H2, not 2009. | ||
if isinstance(version, int): | ||
version = str(version) | ||
assert isinstance(version, str) | ||
try: | ||
if atLeast: | ||
return winVersion.build >= WIN10_VERSIONS_TO_BUILDS[version] | ||
else: | ||
return winVersion.build == WIN10_VERSIONS_TO_BUILDS[version] | ||
except KeyError: | ||
from logHandler import log | ||
log.error("Unknown Windows 10 version {}".format(version)) | ||
log.error(f"Unknown Windows 10 version {version}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this |
||
return False | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the sudden API change from build IDs to xxhx strings. Can we somehow support both? (in other words, 1903 is also 19H1)