40 m_file = wxFileName( aFile );
42 if( !wxFile::Exists(
m_file.GetFullPath() ) )
45 if( !wxFile::Exists(
m_file.GetFullPath() ) )
47 m_info.Printf(
_(
"Script file:\n%s\nnot found. Script not available."), aFile );
54 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" ) )
72 m_cmd = wxString::Format(
"python \"%s/%s\" \"%%I\" \"%%O%s\"",
77 wxString interpreter = wxString::FromUTF8Unchecked( PYTHON_EXECUTABLE );
79 if( interpreter.IsEmpty() )
80 interpreter = wxT(
"python" );
82 m_cmd = wxString::Format(
"%s \"%s\" \"%%I\" \"%%O%s\"",
89 else if( extension == wxS(
"pyw" ) )
92 m_cmd = wxString::Format( wxS(
"pythonw \"%s/%s\" \"%%I\" \"%%O%s\"" ),
109 wxFileName fn( aFile );
110 wxString ext = fn.GetExt().Lower();
112 for(
const auto& pluginExt : { wxS(
"xsl" ), wxS(
"py" ), wxS(
"pyw" ) } )
114 if( pluginExt == ext )
124 if( aEndSection.IsEmpty() )
125 return wxEmptyString;
127 wxFFile fdata(
m_file.GetFullPath(), wxS(
"rb" ) );
130 if( !fdata.ReadAll( &data ) )
131 return wxEmptyString;
133 const wxString
header( wxS(
"@package" ) );
136 size_t strstart = data.find(
header );
138 if( strstart == wxString::npos )
139 return wxEmptyString;
141 strstart +=
header.Length();
142 size_t strend = data.find( aEndSection, strstart );
144 if( strend == wxString::npos )
145 return wxEmptyString;
148 while( data[strstart] <
' ' )
151 return data.SubString( strstart, strend - 1 );
159 const wxString outputarg( wxS(
"\"%O" ) );
161 size_t strstart = aHeader.find( outputarg );
163 if( strstart == wxString::npos )
164 return wxEmptyString;
166 strstart += outputarg.Length();
167 size_t strend = aHeader.find( wxS(
"\"" ), strstart );
169 if( strend == wxString::npos )
170 return wxEmptyString;
172 return aHeader.SubString( strstart, strend - 1 );
178 if(
m_file.IsAbsolute() &&
m_file.Exists( wxFILE_EXISTS_REGULAR ) )
180 wxLogTrace(
BOM_TRACE, wxS(
"%s found directly" ),
m_file.GetFullPath() );
186 if(
test.Exists( wxFILE_EXISTS_REGULAR ) )
188 wxLogTrace(
BOM_TRACE, wxS(
"%s found in user plugins path %s" ),
m_file.GetFullName(),
195 if(
test.Exists( wxFILE_EXISTS_REGULAR ) )
197 wxLogTrace(
BOM_TRACE, wxS(
"%s found in stock plugins path %s" ),
m_file.GetFullName(),
202 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.
std::vector< std::string > header