Fix minor issues. Fix some outdated and broken BOM python scripts. Add info in BOM python scripts.

BOM dialog: remove a not very useful button, and merge its function with an other (not perfect, need more work)
Add message box to show info added in BOM python scripts (See scripts/bom-in-python/README-bom.txt about this info)
This commit is contained in:
jean-pierre charras 2014-12-03 17:22:06 +01:00
parent 479af2a7a8
commit f3765a32d8
24 changed files with 424 additions and 158 deletions

View File

@ -69,7 +69,6 @@ public:
private: private:
void parsePlugin() throw( IO_ERROR, PARSE_ERROR ); void parsePlugin() throw( IO_ERROR, PARSE_ERROR );
}; };
// PCB_PLOT_PARAMS_PARSER // PCB_PLOT_PARAMS_PARSER
@ -175,7 +174,6 @@ private:
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
void OnHelp( wxCommandEvent& event ); void OnHelp( wxCommandEvent& event );
void OnAddPlugin( wxCommandEvent& event ); void OnAddPlugin( wxCommandEvent& event );
void OnChoosePlugin( wxCommandEvent& event );
void OnRemovePlugin( wxCommandEvent& event ); void OnRemovePlugin( wxCommandEvent& event );
void OnEditPlugin( wxCommandEvent& event ); void OnEditPlugin( wxCommandEvent& event );
void OnCommandLineEdited( wxCommandEvent& event ); void OnCommandLineEdited( wxCommandEvent& event );
@ -183,6 +181,18 @@ private:
void pluginInit(); void pluginInit();
void installPluginsList(); void installPluginsList();
wxString getPluginFileName();
/**
* display (when exists) the text found between the keyword "@package"
* and the end of comment block (""" in python", --> in xml)
*/
void displayPluginInfo( FILE * aFile, const wxString& aFilename );
/**
* Browse plugin files, and set m_CommandStringCtrl field
*/
void choosePlugin();
}; };
// Create and show DIALOG_BOM. // Create and show DIALOG_BOM.
@ -215,12 +225,14 @@ DIALOG_BOM::~DIALOG_BOM()
STRING_FORMATTER writer; STRING_FORMATTER writer;
writer.Print( 0, "(plugins" ); writer.Print( 0, "(plugins" );
for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 ) for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 )
{ {
writer.Print( 1, "(plugin %s (cmd %s))", writer.Print( 1, "(plugin %s (cmd %s))",
writer.Quotew( m_plugins[ii] ).c_str(), writer.Quotew( m_plugins[ii] ).c_str(),
writer.Quotew( m_plugins[ii+1] ).c_str() ); writer.Quotew( m_plugins[ii+1] ).c_str() );
} }
writer.Print( 0, ")" ); writer.Print( 0, ")" );
wxString list( FROM_UTF8( writer.GetString().c_str() ) ); wxString list( FROM_UTF8( writer.GetString().c_str() ) );
@ -272,6 +284,7 @@ void DIALOG_BOM::OnPluginSelected( wxCommandEvent& event )
pluginInit(); pluginInit();
} }
#include <wx/ffile.h>
void DIALOG_BOM::pluginInit() void DIALOG_BOM::pluginInit()
{ {
int ii = m_lbPlugins->GetSelection(); int ii = m_lbPlugins->GetSelection();
@ -285,8 +298,67 @@ void DIALOG_BOM::pluginInit()
m_textCtrlName->SetValue( m_plugins[2 * ii] ); m_textCtrlName->SetValue( m_plugins[2 * ii] );
m_textCtrlCommand->SetValue( m_plugins[(2 * ii)+1] ); m_textCtrlCommand->SetValue( m_plugins[(2 * ii)+1] );
wxString pluginName = getPluginFileName();
if( pluginName.IsEmpty() )
return;
FILE* pluginFile = wxFopen( pluginName, "rt" );
if( pluginFile == NULL )
{
wxString msg;
msg.Printf( _( "Failed to open file '%s'" ), GetChars( pluginName ) );
DisplayError( this, msg );
return;
}
displayPluginInfo( pluginFile, pluginName );
} }
/* display (when exists) the text found between the keyword "@package"
* and the end of comment block (""" in python", --> in xml)
*/
void DIALOG_BOM::displayPluginInfo( FILE * aFile, const wxString& aFilename )
{
m_Messages->Clear();
// display (when exists) the text found between the keyword "@package"
// and the end of comment block (""" in python", --> in xml)
wxString data;
wxFFile fdata( aFile ); // dtor will close the file
if( !fdata.ReadAll( &data ) )
return;
wxString header( wxT( "@package" ) );
wxString endsection( wxT( "-->" ) ); // For xml
wxFileName fn( aFilename );
if( fn.GetExt().IsSameAs( wxT("py"), false ) )
endsection = wxT( "\"\"\"" );
// Extract substring between @package and """
int strstart = data.Find( header );
if( strstart == wxNOT_FOUND )
return;
strstart += header.Length();
int strend = data.find( endsection, strstart );
if( strend == wxNOT_FOUND)
return;
// Remove emty line if any
while( data[strstart] < ' ' )
strstart++;
m_Messages->SetValue( data.SubString( strstart, strend-1 ) );
}
/** /**
* Function RunPlugin * Function RunPlugin
@ -351,7 +423,7 @@ void DIALOG_BOM::OnRemovePlugin( wxCommandEvent& event )
void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event ) void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
{ {
// Creates a new plugin entry // Creates a new plugin entry
wxString name = wxGetTextFromUser( _("Plugin") ); wxString name = wxGetTextFromUser( _("Plugin name in plugin list") );
if( name.IsEmpty() ) if( name.IsEmpty() )
return; return;
@ -361,7 +433,7 @@ void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
{ {
if( name == m_plugins[ii] ) if( name == m_plugins[ii] )
{ {
wxMessageBox( _("This plugin already exists. Abort") ); wxMessageBox( _("This name already exists. Abort") );
return; return;
} }
} }
@ -370,13 +442,16 @@ void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
m_plugins.Add( wxEmptyString ); m_plugins.Add( wxEmptyString );
m_lbPlugins->Append( name ); m_lbPlugins->Append( name );
m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 ); m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 );
choosePlugin();
pluginInit(); pluginInit();
} }
/* /*
* Browse plugin files, and set m_CommandStringCtrl field * Browse plugin files, and set m_CommandStringCtrl field
*/ */
void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event ) void DIALOG_BOM::choosePlugin()
{ {
wxString mask = wxT( "*" ); wxString mask = wxT( "*" );
#ifndef __WXMAC__ #ifndef __WXMAC__
@ -417,13 +492,14 @@ void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event )
m_textCtrlCommand->SetValue( cmdLine ); m_textCtrlCommand->SetValue( cmdLine );
} }
void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event )
wxString DIALOG_BOM::getPluginFileName()
{ {
wxString pluginName, cmdline; wxString pluginName;
// Try to find the plugin name. // Try to find the plugin name.
// This is possible if the name ends by .py or .xsl // This is possible if the name ends by .py or .xsl
cmdline = m_textCtrlCommand->GetValue(); wxString cmdline = m_textCtrlCommand->GetValue();
int pos = -1; int pos = -1;
if( (pos = cmdline.Find( wxT(".py") )) != wxNOT_FOUND ) if( (pos = cmdline.Find( wxT(".py") )) != wxNOT_FOUND )
@ -449,9 +525,30 @@ void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event )
// extract the name // extract the name
if( jj >= 0 ) if( jj >= 0 )
{
eos = cmdline[jj];
if( eos == ' '|| eos == '\"' ) // do not include delimiters
jj++;
pluginName = cmdline.SubString( jj, pos ); pluginName = cmdline.SubString( jj, pos );
}
} }
} }
return pluginName;
}
void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event )
{
wxString pluginName = getPluginFileName();
if( pluginName.Length() <= 2 ) // if name != ""
{
wxMessageBox( _("Plugin file name not found. Cannot edit plugin file") );
return;
}
AddDelimiterString( pluginName ); AddDelimiterString( pluginName );
wxString editorname = Pgm().GetEditorName(); wxString editorname = Pgm().GetEditorName();

View File

@ -16,7 +16,6 @@ BEGIN_EVENT_TABLE( DIALOG_BOM_BASE, DIALOG_SHIM )
EVT_BUTTON( wxID_CANCEL, DIALOG_BOM_BASE::_wxFB_OnCancelClick ) EVT_BUTTON( wxID_CANCEL, DIALOG_BOM_BASE::_wxFB_OnCancelClick )
EVT_BUTTON( ID_HELP, DIALOG_BOM_BASE::_wxFB_OnHelp ) EVT_BUTTON( ID_HELP, DIALOG_BOM_BASE::_wxFB_OnHelp )
EVT_BUTTON( ID_ADD_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnAddPlugin ) EVT_BUTTON( ID_ADD_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnAddPlugin )
EVT_BUTTON( wxID_BROWSE_PLUGINS, DIALOG_BOM_BASE::_wxFB_OnChoosePlugin )
EVT_BUTTON( ID_REMOVEL_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnRemovePlugin ) EVT_BUTTON( ID_REMOVEL_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnRemovePlugin )
EVT_BUTTON( wxID_ANY, DIALOG_BOM_BASE::_wxFB_OnEditPlugin ) EVT_BUTTON( wxID_ANY, DIALOG_BOM_BASE::_wxFB_OnEditPlugin )
EVT_TEXT( ID_CMDLINE, DIALOG_BOM_BASE::_wxFB_OnCommandLineEdited ) EVT_TEXT( ID_CMDLINE, DIALOG_BOM_BASE::_wxFB_OnCommandLineEdited )
@ -72,9 +71,6 @@ DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxStrin
m_buttonAddPlugin = new wxButton( this, ID_ADD_PLUGIN, _("Add Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonAddPlugin = new wxButton( this, ID_ADD_PLUGIN, _("Add Plugin"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonAddPlugin, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); bRightSizer->Add( m_buttonAddPlugin, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonBrowsePlugin = new wxButton( this, wxID_BROWSE_PLUGINS, _("Set Plugin Cmd"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonBrowsePlugin, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonDelPlugin = new wxButton( this, ID_REMOVEL_PLUGIN, _("Remove Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonDelPlugin = new wxButton( this, ID_REMOVEL_PLUGIN, _("Remove Plugin"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonDelPlugin, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); bRightSizer->Add( m_buttonDelPlugin, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
@ -103,6 +99,13 @@ DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxStrin
bMainSizer->Add( bbottomSizer, 0, wxEXPAND, 5 ); bMainSizer->Add( bbottomSizer, 0, wxEXPAND, 5 );
m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("Plugin Info:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInfo->Wrap( -1 );
bMainSizer->Add( m_staticTextInfo, 0, wxRIGHT|wxLEFT, 5 );
m_Messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
bMainSizer->Add( m_Messages, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );
this->Layout(); this->Layout();

View File

@ -44,7 +44,7 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">DIALOG_BOM_BASE</property> <property name="name">DIALOG_BOM_BASE</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">404,315</property> <property name="size">409,393</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Bill of Material</property> <property name="title">Bill of Material</property>
@ -900,94 +900,6 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_BROWSE_PLUGINS</property>
<property name="label">Set Plugin Cmd</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonBrowsePlugin</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnChoosePlugin</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
@ -1353,6 +1265,180 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Plugin Info:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextInfo</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Messages</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxTE_MULTILINE|wxTE_READONLY</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object> </object>
</object> </object>
</object> </object>

View File

@ -44,7 +44,6 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM
void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); }
void _wxFB_OnHelp( wxCommandEvent& event ){ OnHelp( event ); } void _wxFB_OnHelp( wxCommandEvent& event ){ OnHelp( event ); }
void _wxFB_OnAddPlugin( wxCommandEvent& event ){ OnAddPlugin( event ); } void _wxFB_OnAddPlugin( wxCommandEvent& event ){ OnAddPlugin( event ); }
void _wxFB_OnChoosePlugin( wxCommandEvent& event ){ OnChoosePlugin( event ); }
void _wxFB_OnRemovePlugin( wxCommandEvent& event ){ OnRemovePlugin( event ); } void _wxFB_OnRemovePlugin( wxCommandEvent& event ){ OnRemovePlugin( event ); }
void _wxFB_OnEditPlugin( wxCommandEvent& event ){ OnEditPlugin( event ); } void _wxFB_OnEditPlugin( wxCommandEvent& event ){ OnEditPlugin( event ); }
void _wxFB_OnCommandLineEdited( wxCommandEvent& event ){ OnCommandLineEdited( event ); } void _wxFB_OnCommandLineEdited( wxCommandEvent& event ){ OnCommandLineEdited( event ); }
@ -57,7 +56,6 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM
ID_CREATE_BOM, ID_CREATE_BOM,
ID_HELP, ID_HELP,
ID_ADD_PLUGIN, ID_ADD_PLUGIN,
wxID_BROWSE_PLUGINS,
ID_REMOVEL_PLUGIN, ID_REMOVEL_PLUGIN,
ID_CMDLINE ID_CMDLINE
}; };
@ -71,11 +69,12 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM
wxButton* m_buttonHelp; wxButton* m_buttonHelp;
wxStaticLine* m_staticline2; wxStaticLine* m_staticline2;
wxButton* m_buttonAddPlugin; wxButton* m_buttonAddPlugin;
wxButton* m_buttonBrowsePlugin;
wxButton* m_buttonDelPlugin; wxButton* m_buttonDelPlugin;
wxButton* m_buttonEdit; wxButton* m_buttonEdit;
wxStaticText* m_staticTextCmd; wxStaticText* m_staticTextCmd;
wxTextCtrl* m_textCtrlCommand; wxTextCtrl* m_textCtrlCommand;
wxStaticText* m_staticTextInfo;
wxTextCtrl* m_Messages;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnPluginSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnPluginSelected( wxCommandEvent& event ) { event.Skip(); }
@ -84,7 +83,6 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddPlugin( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddPlugin( wxCommandEvent& event ) { event.Skip(); }
virtual void OnChoosePlugin( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemovePlugin( wxCommandEvent& event ) { event.Skip(); } virtual void OnRemovePlugin( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditPlugin( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditPlugin( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCommandLineEdited( wxCommandEvent& event ) { event.Skip(); } virtual void OnCommandLineEdited( wxCommandEvent& event ) { event.Skip(); }
@ -92,7 +90,7 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM
public: public:
DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 404,315 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 409,393 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_BOM_BASE(); ~DIALOG_BOM_BASE();
}; };

View File

@ -381,7 +381,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList
NETLIST_EXPORT_TOOL helper( aConnectedItemsList, Prj().SchLibs() ); NETLIST_EXPORT_TOOL helper( aConnectedItemsList, Prj().SchLibs() );
bool open_file = aFormat < NET_TYPE_CUSTOM1; bool open_file = (aFormat < NET_TYPE_CUSTOM1) && (aFormat >= 0);
if( (aFormat == NET_TYPE_PCBNEW) && (aNetlistOptions & NET_PCBNEW_USE_NEW_FORMAT ) ) if( (aFormat == NET_TYPE_PCBNEW) && (aNetlistOptions & NET_PCBNEW_USE_NEW_FORMAT ) )
open_file = false; open_file = false;
@ -390,7 +390,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Failed to create file <%s>" ), msg.Printf( _( "Failed to create file '%s'" ),
GetChars( aFullFileName ) ); GetChars( aFullFileName ) );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;

View File

@ -19,6 +19,14 @@
in the filename. in the filename.
--> -->
<!--
@package
Generate a Tab delimited list (csv file type).
One component per line
Fields are
Ref,Value, Footprint, Datasheet, Field5, Field4, price
-->
<!DOCTYPE xsl:stylesheet [ <!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF, or LF, your choice --> <!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF, or LF, your choice -->
]> ]>

View File

@ -7,6 +7,14 @@
How to use: How to use:
Eeschema.pdf: chapter 14 Eeschema.pdf: chapter 14
--> -->
<!--
@package
Generate a Tab delimited list (csv file type).
Components are sorted by value
One component per line
Fields are
Quantity, 'Part name', 'Description', 'lib'
-->
<!DOCTYPE xsl:stylesheet [ <!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF --> <!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF -->
@ -18,20 +26,18 @@
<!-- for each component --> <!-- for each component -->
<xsl:template match="libpart"> <xsl:template match="libpart">
<!-- <!-- -->
<xsl:value-of select="count(//comp/libsource/@part[@part])"/><xsl:text>,</xsl:text> <xsl:value-of select="count(//comp/libsource/@part[@part])"/><xsl:text>,"</xsl:text>
--> <xsl:value-of select="@part"/><xsl:text>","</xsl:text>
<xsl:value-of select="description"/><xsl:text>","</xsl:text>
<xsl:value-of select="@part"/><xsl:text>,</xsl:text>
<xsl:value-of select="description"/><xsl:text>,</xsl:text>
<xsl:value-of select="@lib"/> <xsl:value-of select="@lib"/>
<xsl:text>&nl;</xsl:text> <xsl:text>"&nl;</xsl:text>
</xsl:template> </xsl:template>
<xsl:template match="/export"> <xsl:template match="/export">
<xsl:text>qty,partname,description,lib&nl;</xsl:text> <xsl:text>Qty,partname,description,lib&nl;</xsl:text>
<xsl:apply-templates select="libparts/libpart"/> <xsl:apply-templates select="libparts/libpart"/>
</xsl:template> </xsl:template>

View File

@ -90,9 +90,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout ) EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
EVT_TOOL( wxID_CUT, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_COPY, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, GERBVIEW_FRAME::Process_Special_Functions ) EVT_TOOL( wxID_UNDO, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, GERBVIEW_FRAME::ToPrinter ) EVT_TOOL( wxID_PRINT, GERBVIEW_FRAME::ToPrinter )
EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
@ -145,9 +142,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case wxID_CUT:
case wxID_COPY:
case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
break; break;
@ -219,12 +213,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_DELETE_BLOCK:
GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE );
GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
default: default:
wxFAIL_MSG( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) ); wxFAIL_MSG( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) );
break; break;

View File

@ -80,7 +80,7 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event )
break; break;
case ID_GERBVIEW_ERASE_ALL: case ID_GERBVIEW_ERASE_ALL:
Clear_DrawLayers( true ); Clear_DrawLayers( false );
Zoom_Automatique( false ); Zoom_Automatique( false );
m_canvas->Refresh(); m_canvas->Refresh();
ClearMsgPanel(); ClearMsgPanel();

View File

@ -24,7 +24,6 @@
#include <fctsys.h> #include <fctsys.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h>
#include <id.h> #include <id.h>
#include <gerbview.h> #include <gerbview.h>
@ -75,8 +74,6 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK, AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK,
_( "Place Block" ), KiBitmap( checked_ok_xpm ) ); _( "Place Block" ), KiBitmap( checked_ok_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK,
_( "Delete Block (ctrl + drag mouse)" ), KiBitmap( delete_xpm ) );
} }
else else
{ {

View File

@ -999,7 +999,6 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
double angle = aPad.GetOrientation(); double angle = aPad.GetOrientation();
int rounding_radius = KiROUND( aThermalGap * aCorrectionFactor ); // Corner rounding radius int rounding_radius = KiROUND( aThermalGap * aCorrectionFactor ); // Corner rounding radius
double angle_pg; // Polygon increment angle
for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ )
{ {
@ -1007,7 +1006,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer,
// Start at half increment offset // Start at half increment offset
RotatePoint( &corner_position, 1800.0 / aCircleToSegmentsCount ); RotatePoint( &corner_position, 1800.0 / aCircleToSegmentsCount );
angle_pg = i * delta; double angle_pg = i * delta;
RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation
corner_position -= aPad.GetSize() / 2; // Rounding vector + Pad corner offset corner_position -= aPad.GetSize() / 2; // Rounding vector + Pad corner offset

View File

@ -541,6 +541,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_DELETE_ZONE_CONTAINER: case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
// Force the main contour selection, to remove the entire zone:
((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 );
// Fall through
case ID_POPUP_PCB_DELETE_ZONE_CUTOUT: case ID_POPUP_PCB_DELETE_ZONE_CUTOUT:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
{ {

View File

@ -29,7 +29,6 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
//#include <pgm_base.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>

View File

@ -13,7 +13,7 @@ from sys import argv,exit
if len(argv)<2: if len(argv)<2:
print "usage:" print "usage:"
print " fixswigimports.py file.py" print " fix_swig_imports.py file.py"
print "" print ""
print " will fix the swig import code for working inside KiCad" print " will fix the swig import code for working inside KiCad"
print " where it happended that the external _pcbnew.so/dll was" print " where it happended that the external _pcbnew.so/dll was"
@ -52,7 +52,7 @@ if doneOk:
print "swig_import_helper fixed for",filename print "swig_import_helper fixed for",filename
else: else:
print "Error: the swig import helper was not fixed, check",filename print "Error: the swig import helper was not fixed, check",filename
print " and fix this script: fixswigimports.py" print " and fix this script: fix_swig_imports.py"
exit(2) exit(2)

View File

@ -1,7 +1,7 @@
bom_?.py are some python scripts which read a generic xml netlist from eeschema, bom_?.py are some python scripts which read a generic xml netlist from eeschema,
and create a bom. and create a bom.
All examples use ky_generic_netlist_reader.py, which is a python utility to read All examples use ky_netlist_reader.py, which is a python utility to read
and parse this generic xml netlist and create the corresponding data and parse this generic xml netlist and create the corresponding data
used to build the bom. used to build the bom.
@ -12,3 +12,27 @@ python bom_example?.py <netlist name> <bom list netname>
See Eeschema doc, chapter 14 for info about the generic xml netlist format, See Eeschema doc, chapter 14 for info about the generic xml netlist format,
and how to run a script from Eeschema to create a customized netlist or BOM. and how to run a script from Eeschema to create a customized netlist or BOM.
If the python comment
"""
@package
some comments
"""
is added to the begining of the python script, the comment will be displayed
in Eescheam, in the BOM dialog
For instance:
"""
@package
Generate a HTML BOM list.
Components are sorted and grouped by value
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
"""
displays:
Generate a HTML BOM list.
Components are sorted and grouped by value
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
in BOM dialog

View File

@ -4,6 +4,15 @@
# Example: Sorted and Grouped HTML BOM with more advanced grouping # Example: Sorted and Grouped HTML BOM with more advanced grouping
# #
"""
@package
Generate a HTML BOM list.
Components are sorted and grouped by value
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
"""
from __future__ import print_function from __future__ import print_function
# Import the KiCad python helper module and the csv formatter # Import the KiCad python helper module and the csv formatter
@ -74,8 +83,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
e = "Can't open output file for writing: " + sys.argv[2]
print(__file__, ":", e, file=sys.stderr) print(__file__, ":", e, file=sys.stderr)
f = stdout f = sys.stdout
# Output a set of rows for a header providing general information # Output a set of rows for a header providing general information
html = html.replace('<!--SOURCE-->', net.getSource()) html = html.replace('<!--SOURCE-->', net.getSource())

View File

@ -1,8 +1,14 @@
# #
# Example python script to generate a BOM from a KiCad generic netlist # Example python script to generate a BOM from a KiCad generic netlist
# #
# Example: Tab delimited list (The same as std output) Ungrouped """
# @package
Generate a csv list file.
Components are sorted by ref and grouped by value
One component per line
Fields are (if exist)
Ref, Quantity, value, Part, 'footprint', 'Description', 'Vendor'
"""
from __future__ import print_function from __future__ import print_function
@ -20,8 +26,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
print(__file__, ":", e, file=sys.stderr) e = "Can't open output file for writing: " + sys.argv[2]
f = stdout print(__file__, ":", e, sys.stderr)
f = sys.stdout
# Create a new csv writer object to use as the output formatter, although we # Create a new csv writer object to use as the output formatter, although we
# are created a tab delimited list instead! # are created a tab delimited list instead!

View File

@ -4,6 +4,15 @@
# Example: Ungrouped (One component per row) CSV output # Example: Ungrouped (One component per row) CSV output
# #
"""
@package
Generate a csv list file.
Components are sorted by ref and grouped by value
One component per line
Fields are (if exist)
Ref, value, Part, footprint, Datasheet, Manufacturer, Vendor
"""
from __future__ import print_function from __future__ import print_function
# Import the KiCad python helper module # Import the KiCad python helper module
@ -20,8 +29,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
print(__file__, ":", e, file=sys.stderr) e = "Can't open output file for writing: " + sys.argv[2]
f = stdout print( __file__, ":", e, sys.stderr )
f = sys.stdout
# Create a new csv writer object to use as the output formatter # Create a new csv writer object to use as the output formatter
out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar="\"", quoting=csv.QUOTE_ALL) out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar="\"", quoting=csv.QUOTE_ALL)

View File

@ -27,7 +27,7 @@ try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
e = "Can't open output file for writing: " + sys.argv[2] e = "Can't open output file for writing: " + sys.argv[2]
print(__file__, ":", e, file=sys.stderr) print( __file__, ":", e, sys.stderr )
f = sys.stdout f = sys.stdout
# subset the components to those wanted in the BOM, controlled # subset the components to those wanted in the BOM, controlled
@ -46,7 +46,7 @@ columnset = compfields | partfields # union
columns = ['Item', 'Qty', 'Reference(s)', 'Value', 'LibPart', 'Footprint', 'Datasheet'] + sorted(list(columnset)) columns = ['Item', 'Qty', 'Reference(s)', 'Value', 'LibPart', 'Footprint', 'Datasheet'] + sorted(list(columnset))
# Create a new csv writer object to use as the output formatter # Create a new csv writer object to use as the output formatter
out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL) out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL )
# override csv.writer's writerow() to support utf8 encoding: # override csv.writer's writerow() to support utf8 encoding:
def writerow( acsvwriter, columns ): def writerow( acsvwriter, columns ):

View File

@ -4,6 +4,15 @@
# Example: Sorted and Grouped HTML BOM with more advanced grouping # Example: Sorted and Grouped HTML BOM with more advanced grouping
# #
"""
@package
Generate a HTML BOM list.
Components are sorted and grouped by ref
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
"""
from __future__ import print_function from __future__ import print_function
# Import the KiCad python helper module and the csv formatter # Import the KiCad python helper module and the csv formatter
@ -74,8 +83,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
print(__file__, ":", e, file=sys.stderr) e = "Can't open output file for writing: " + sys.argv[2]
f = stdout print( __file__, ":", e, sys.stderr )
f = sys.stdout
components = net.getInterestingComponents() components = net.getInterestingComponents()

View File

@ -3,6 +3,13 @@
# #
# Example: Sorted and Grouped HTML BOM # Example: Sorted and Grouped HTML BOM
# #
"""
@package
Generate a HTML BOM list.
Components are sorted by ref and grouped by value
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
"""
from __future__ import print_function from __future__ import print_function
@ -39,8 +46,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
e = "Can't open output file for writing: " + sys.argv[2]
print(__file__, ":", e, file=sys.stderr) print(__file__, ":", e, file=sys.stderr)
f = stdout f = sys.stdout
components = net.getInterestingComponents() components = net.getInterestingComponents()
@ -51,7 +59,8 @@ html = html.replace('<!--TOOL-->', net.getTool())
html = html.replace('<!--COMPCOUNT-->', "<b>Component Count:</b>" + \ html = html.replace('<!--COMPCOUNT-->', "<b>Component Count:</b>" + \
str(len(components))) str(len(components)))
row = "<tr><th style='width:640px'>Ref</th>" + "<th>Qnty</th>" row = "<tr><th style='width:640px'>Ref</th>"
row += "<th>Qnty</th>"
row += "<th>Value</th>" + "<th>Part</th>" + "<th>Datasheet</th>" row += "<th>Value</th>" + "<th>Part</th>" + "<th>Datasheet</th>"
row += "<th>Description</th>" + "<th>Vendor</th></tr>" row += "<th>Description</th>" + "<th>Vendor</th></tr>"
@ -74,10 +83,11 @@ for group in grouped:
c = component c = component
row = "<tr><td>" + refs +"</td><td>" + str(len(group)) row = "<tr><td>" + refs +"</td><td>" + str(len(group))
row += "</td><td>" + c.getValue() + "</td><td>" + c.getLibName() + ":" row += "</td><td>" + c.getValue()
row += c.getPartName() + "</td><td>" + c.getDatasheet() + "</td><td>" row += "</td><td>" + c.getLibName() + ":" + c.getPartName()
row += c.getDescription() + "</td><td>" + c.getField("Vendor") row += "</td><td>" + c.getDatasheet()
row += "</td></tr>" row += "</td><td>" + c.getDescription()
row += "</td><td>" + c.getField("Vendor")+ "</td></tr>"
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->") html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")

View File

@ -7,6 +7,15 @@
# is due to be deprecated in 3.0+ soon # is due to be deprecated in 3.0+ soon
# #
"""
@package
Generate a HTML BOM list.
Components are sorted and grouped by value
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
"""
from __future__ import print_function from __future__ import print_function
import sys import sys
import xml.sax as sax import xml.sax as sax

View File

@ -21,7 +21,8 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
print( __file__, ":", e, file=sys.stderr) e = "Can't open output file for writing: " + sys.argv[2]
f = stdout print( __file__, ":", e, sys.stderr)
f = sys.stdout
print(net.formatXML(), file=f) print(net.formatXML(), file=f)

View File

@ -64,8 +64,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
try: try:
f = open(sys.argv[2], 'w') f = open(sys.argv[2], 'w')
except IOError: except IOError:
e = "Can't open output file for writing: " + sys.argv[2]
print(__file__, ":", e, file=sys.stderr) print(__file__, ":", e, file=sys.stderr)
f = stdout f = sys.stdout
for c in net.components: for c in net.components:
c.checkvalue() c.checkvalue()