35 : m_storedPath( aFile )
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();
59 if( extension ==
"xsl" )
65 else if( extension ==
"py" )
78 else if( extension ==
"pyw" )
97 wxFileName fn( aFile );
98 wxString ext = fn.GetExt().Lower();
100 for(
const auto& pluginExt : {
"xsl",
"py",
"pyw" } )
102 if( pluginExt == ext )
112 if( aEndSection.IsEmpty() )
113 return wxEmptyString;
115 wxFFile fdata(
m_file.GetFullPath(),
"rb" );
118 if( !fdata.ReadAll( &data ) )
119 return wxEmptyString;
121 const wxString header(
"@package" );
124 int strstart = data.Find( header );
126 if( strstart == wxNOT_FOUND )
127 return wxEmptyString;
129 strstart += header.Length();
130 int strend = data.find( aEndSection, strstart );
132 if( strend == wxNOT_FOUND )
133 return wxEmptyString;
136 while( data[strstart] <
' ' )
139 return data.SubString( strstart, strend - 1 );
147 const wxString outputarg(
"\"%O" );
149 int strstart = aHeader.Find( outputarg );
151 if( strstart == wxNOT_FOUND )
152 return wxEmptyString;
154 strstart += outputarg.Length();
155 int strend = aHeader.find(
"\"", strstart );
157 if( strend == wxNOT_FOUND )
158 return wxEmptyString;
160 return aHeader.SubString( strstart, strend - 1 );
166 if(
m_file.IsAbsolute() &&
m_file.Exists( wxFILE_EXISTS_REGULAR ) )
174 if(
test.Exists( wxFILE_EXISTS_REGULAR ) )
176 wxLogTrace(
BOM_TRACE,
"%s found in user plugins path %s",
m_file.GetFullName(),
183 if(
test.Exists( wxFILE_EXISTS_REGULAR ) )
185 wxLogTrace(
BOM_TRACE,
"%s found in stock plugins path %s",
m_file.GetFullName(),
190 wxLogTrace(
BOM_TRACE,
"Could not find %s (checked %s, %s)",
m_file.GetFullName(),
wxString readHeader(const wxString &aEndSection)
Read the plugin file header.
wxFileName m_file
Path to the plugin stored in config (can be absolute or just a filename)
wxString m_cmd
Description of the plugin (normally from the plugin header)
static wxString GetUserPluginsPath()
Gets the user path for plugins.
wxFileName FindFilePath() const
Returns the calculated path to the plugin: if the path is already absolute and exists,...
static bool IsValidGenerator(const wxString &aFile)
Return true if a file name matches a recognized plugin format.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
BOM_GENERATOR_HANDLER(const wxString &aFile)
static wxString getOutputExtension(const wxString &aHeader)
Extracts the output BOM file's extension, including the '.
wxString m_name
Command to execute the plugin.
wxString m_info
Plugin specific options.
bool m_isOk
Path to the plugin.
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.