File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131CO_E_OBJNOTCONNECTED = - 2147220995
3232EVENT_E_ALL_SUBSCRIBERS_FAILED = - 2147220991
3333LOAD_WITH_ALTERED_SEARCH_PATH = 0x8
34+ _NVDA_CODE_PATH = os .path .dirname (__file__ )
35+ """Store path in which NVDA code is placed.
36+ We cannot use `globalVars.appDir`, since for binary builds it points to the directory with NVDA binaries,
37+ whereas for compiled versions NVDA's code files are in `library.zip`.
38+ """
3439
3540
3641def isPathExternalToNVDA (path : str ) -> bool :
3742 """ Checks if the given path is external to NVDA (I.e. not pointing to built-in code). """
3843 if (
3944 path [0 ] != "<"
4045 and os .path .isabs (path )
41- and not os .path .normpath (path ).startswith (sys .path [0 ] + "\\ " )
46+ and not os .path .normpath (path ).startswith (_NVDA_CODE_PATH + "\\ " )
47+ or (
48+ globalVars .appArgs .configPath is not None # Handle messages logged before config is initialized
49+ and path .startswith (globalVars .appArgs .configPath )
50+ )
4251 ):
4352 # This module is external because:
4453 # the code comes from a file (fn doesn't begin with "<");
4554 # it has an absolute file path (code bundled in binary builds reports relative paths); and
46- # it is not part of NVDA's Python code (not beneath sys.path[0]).
55+ # it is not part of NVDA's Python code
56+ # (i.e. outside of NVDA directory or in NVDA's config,
57+ # so belongs to an add-on or a plugin in the scratchpad).
4758 return True
4859 return False
4960
61+
5062def getCodePath (f ):
5163 """Using a frame object, gets its module path (relative to the current directory).[className.[funcName]]
5264 @param f: the frame object to use
You can’t perform that action at this time.
0 commit comments