38 m_file = wxFileName( aFile );
40 if( !wxFile::Exists(
m_file.GetFullPath() ) )
43 if( !wxFile::Exists(
m_file.GetFullPath() ) )
45 m_info.Printf(
_(
"Script file:\n%s\nnot found. Script not available."), aFile );
52 wxString extension =
m_file.GetExt().Lower();
61 if( extension == wxS(
"xsl" ) )
64 m_cmd = wxString::Format( wxS(
"xsltproc -o \"%%O%s\" \"%s\" \"%%I\"" ),
68 else if( extension == wxS(
"py" ) )
73 m_cmd = wxString::Format(
"\"%s\" \"%s/%s\" \"%%I\" \"%%O%s\"",
79 wxString interpreter = wxString::FromUTF8Unchecked( python );
81 if( interpreter.IsEmpty() )
82 interpreter = wxT(
"python" );
84 m_cmd = wxString::Format(
"%s \"%s\" \"%%I\" \"%%O%s\"",
91 else if( extension == wxS(
"pyw" ) )
93 python.Replace(
"python.exe",
"pythonw.exe" );
95 m_cmd = wxString::Format( wxS(
"\"%s\" \"%s/%s\" \"%%I\" \"%%O%s\"" ),
113 wxFileName fn( aFile );
114 wxString ext = fn.GetExt().Lower();
116 for(
const auto& pluginExt : { wxS(
"xsl" ), wxS(
"py" ), wxS(
"pyw" ) } )
118 if( pluginExt == ext )
128 if( aEndSection.IsEmpty() )
129 return wxEmptyString;
131 wxFFile fdata(
m_file.GetFullPath(), wxS(
"rb" ) );
134 if( !fdata.ReadAll( &data ) )
135 return wxEmptyString;
137 const wxString header( wxS(
"@package" ) );
140 size_t strstart = data.find( header );
142 if( strstart == wxString::npos )
143 return wxEmptyString;
145 strstart += header.Length();
146 size_t strend = data.find( aEndSection, strstart );
148 if( strend == wxString::npos )
149 return wxEmptyString;
152 while( data[strstart] <
' ' )
155 return data.SubString( strstart, strend - 1 );
163 const wxString outputarg( wxS(
"\"%O" ) );
165 size_t strstart = aHeader.find( outputarg );
167 if( strstart == wxString::npos )
168 return wxEmptyString;
170 strstart += outputarg.Length();
171 size_t strend = aHeader.find( wxS(
"\"" ), strstart );
173 if( strend == wxString::npos )
174 return wxEmptyString;
176 return aHeader.SubString( strstart, strend - 1 );
182 if(
m_file.IsAbsolute() &&
m_file.Exists( wxFILE_EXISTS_REGULAR ) )
184 wxLogTrace(
BOM_TRACE, wxS(
"%s found directly" ),
m_file.GetFullPath() );
190 if(
test.Exists( wxFILE_EXISTS_REGULAR ) )
192 wxLogTrace(
BOM_TRACE, wxS(
"%s found in user plugins path %s" ),
m_file.GetFullName(),
199 if(
test.Exists( wxFILE_EXISTS_REGULAR ) )
201 wxLogTrace(
BOM_TRACE, wxS(
"%s found in stock plugins path %s" ),
m_file.GetFullName(),
206 wxLogTrace(
BOM_TRACE, wxS(
"Could not find %s (checked %s, %s)" ),
m_file.GetFullName(),
wxString m_name
Command to execute the plugin.
static bool IsValidGenerator(const wxString &aFile)
Return true if a file name matches a recognized plugin format.
wxString readHeader(const wxString &aEndSection)
Read the plugin file header.
bool m_isOk
Path to the plugin.
BOM_GENERATOR_HANDLER(const wxString &aFile)
wxString m_info
Plugin specific options.
wxFileName m_file
Path to the plugin stored in config (can be absolute or just a filename)
const wxString m_storedPath
User customisable name.
wxString m_cmd
Description of the plugin (normally from the plugin header)
wxFileName FindFilePath() const
Returns the calculated path to the plugin: if the path is already absolute and exists,...
static wxString getOutputExtension(const wxString &aHeader)
Extracts the output BOM file's extension, including the '.
static wxString GetUserPluginsPath()
Gets the user path for plugins.
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.
virtual COMMON_SETTINGS * GetCommonSettings() const
PGM_BASE & Pgm()
The global program "get" accessor.
wxString python_interpreter