Refinements for commit 986b904

(Add comments and a minor fix)
This commit is contained in:
jean-pierre charras 2018-04-27 16:01:46 +02:00
parent bc67d1ad8c
commit ccce376e33
2 changed files with 16 additions and 5 deletions

View File

@ -451,8 +451,7 @@ wxString PyScriptingPath()
scriptPath.MakeAbsolute();
// Convert '\' to '/' in path, because later python script read \n or \r
// as escaped sequence, and create issues. Moreover, python uses unix notation in paths
// in many cases.
// as escaped sequence, and create issues, when calling it by PyRun_SimpleString() method.
// It can happen on Windows.
path = scriptPath.GetFullPath();
path.Replace( '\\', '/' );
@ -462,5 +461,7 @@ wxString PyScriptingPath()
wxString PyPluginsPath()
{
return PyScriptingPath() + wxFileName::GetPathSeparator() + "plugins";
// Note we are using unix path separator, because window separator sometimes
// creates issues when passing a command string to a python method by PyRun_SimpleString
return PyScriptingPath() + '/' + "plugins";
}

View File

@ -169,10 +169,13 @@ def LoadPlugins(bundlepath=None):
Arguments:
bundlepath -- The path to the bundled scripts.
The bunbled Plugins are relative to this path, in the
The bundled Plugins are relative to this path, in the
"plugins" subdirectory.
WARNING: bundlepath must use '/' as path separator, and not '\'
because it creates issues (\n and \r are seen as escaped seq)
because it creates issues:
\n and \r are seen as a escaped seq when passing this string to this method
I am thinking this is due to the fact LoadPlugins is called from C++ code by
PyRun_SimpleString()
NOTE: These are all of the possible "default" search paths for kicad
python scripts. These paths will ONLY be added to the python
@ -204,6 +207,13 @@ def LoadPlugins(bundlepath=None):
config_path = pcbnew.GetKicadConfigPath()
plugin_directories=[]
"""
To be consistent with others paths, on windows, convert the unix '/' separator
to the windows separator, although using '/' works
"""
if sys.platform.startswith('win32'):
bundlepath = bundlepath.replace("/","\\")
if bundlepath:
plugin_directories.append(bundlepath)
plugin_directories.append(os.path.join(bundlepath, 'plugins'))