-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
Move some classes from the main gui module. #12105
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b78d92
Move some classes and functions from the gui module
lukaszgo1 9b5a7d3
Remove unused imports from the gui module
lukaszgo1 1c52d96
Merge branch 'master' into I11950
lukaszgo1 ef7a0eb
Merge branch 'master' into I11950
lukaszgo1 04ad286
Review actions
lukaszgo1 b3e3549
update changes.t2t
seanbudd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: UTF-8 -*- | ||
# A part of NonVisual Desktop Access (NVDA) | ||
# Copyright (C) 2006-2021 NV Access Limited, Łukasz Golonka | ||
# This file may be used under the terms of the GNU General Public License, version 2 or later. | ||
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
import os | ||
import sys | ||
|
||
import globalVars | ||
import languageHandler | ||
|
||
|
||
def getDocFilePath(fileName, localized=True): | ||
if not getDocFilePath.rootPath: | ||
if hasattr(sys, "frozen"): | ||
getDocFilePath.rootPath = os.path.join(globalVars.appDir, "documentation") | ||
else: | ||
getDocFilePath.rootPath = os.path.join(globalVars.appDir, "..", "user_docs") | ||
|
||
if localized: | ||
lang = languageHandler.getLanguage() | ||
tryLangs = [lang] | ||
if "_" in lang: | ||
# This locale has a sub-locale, but documentation might not exist for the sub-locale, so try stripping it. | ||
tryLangs.append(lang.split("_")[0]) | ||
# If all else fails, use English. | ||
tryLangs.append("en") | ||
|
||
fileName, fileExt = os.path.splitext(fileName) | ||
for tryLang in tryLangs: | ||
tryDir = os.path.join(getDocFilePath.rootPath, tryLang) | ||
if not os.path.isdir(tryDir): | ||
continue | ||
|
||
# Some out of date translations might include .txt files which are now .html files in newer translations. | ||
# Therefore, ignore the extension and try both .html and .txt. | ||
for tryExt in ("html", "txt"): | ||
tryPath = os.path.join(tryDir, f"{fileName}.{tryExt}") | ||
if os.path.isfile(tryPath): | ||
return tryPath | ||
return None | ||
else: | ||
# Not localized. | ||
if not hasattr(sys, "frozen") and fileName in ("copying.txt", "contributors.txt"): | ||
# If running from source, these two files are in the root dir. | ||
return os.path.join(globalVars.appDir, "..", fileName) | ||
else: | ||
return os.path.join(getDocFilePath.rootPath, fileName) | ||
|
||
|
||
getDocFilePath.rootPath = None |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we are trying to avoid these imports that aren't at the top of file, or the most outer scope when this isn't possible. Since
gui
has already been imported at the top ofdoStartupDialogs
, if you want to importWelcomeDialog
directly, it would be preferable to add thefrom gui.startupDialogs import WelcomeDialog
statement to the top ofdoStartupDialogs
.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.
It is a matter of style obviously, however since
WelcomeDialog
is used only for users who haven't disabled it so a very small percentage isn't it wasteful to always import it rather than do it conditionally as it is done now?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.
yes, definitely a matter of preference. From a discussion with another developer these are fine as is. However in this case wouldn't there be no performance changes because the entire
gui
module has already been imported in the same scope?