summaryrefslogtreecommitdiff
path: root/scripts/test_plugin.py
diff options
context:
space:
mode:
authorsaurabhb172020-02-26 16:40:14 +0530
committerGitHub2020-02-26 16:40:14 +0530
commit02c614b4e64b68758f223391cb5357b3eec78cac (patch)
treead18839d8b4eb1f13419d07878cc4ec4c9b70032 /scripts/test_plugin.py
parentb77f5d9d8097c38159c6f60917995d6af13bbe1c (diff)
parent07a8c86216b6b1f694b136ec64c281d62941952e (diff)
downloadKiCad-eSim-02c614b4e64b68758f223391cb5357b3eec78cac.tar.gz
KiCad-eSim-02c614b4e64b68758f223391cb5357b3eec78cac.tar.bz2
KiCad-eSim-02c614b4e64b68758f223391cb5357b3eec78cac.zip
Merge pull request #6 from saurabhb17/master
minor additions
Diffstat (limited to 'scripts/test_plugin.py')
-rwxr-xr-xscripts/test_plugin.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/test_plugin.py b/scripts/test_plugin.py
new file mode 100755
index 0000000..3755607
--- /dev/null
+++ b/scripts/test_plugin.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+# Test a basic back to back FootprintLoad() of a single footprint, and FootprintEnumerate()
+
+# 1) Build target _pcbnew after enabling scripting in cmake.
+# $ make _pcbnew
+
+# 2) Changed dir to pcbnew
+# $ cd pcbnew
+# $ pwd
+# build/pcbnew
+
+# 3) Entered following command line, script takes to arguments: library_path [footprint_name]
+# $ PYTHONPATH=. <path_to>/test_plugin.py https://github.com/liftoff-sr/pretty_footprints [100-LQFP]
+
+
+from __future__ import print_function
+from pcbnew import *
+import sys
+
+if len( sys.argv ) < 2 :
+ print( "usage: script <library_path> [<footprint_name>]" )
+ sys.exit(1)
+
+
+src_libpath = sys.argv[1]
+
+
+src_type = IO_MGR.GuessPluginTypeFromLibPath( src_libpath );
+
+src_plugin = IO_MGR.PluginFind( src_type )
+
+if len( sys.argv ) == 2:
+ list_of_footprints = src_plugin.FootprintEnumerate( src_libpath )
+ for fp in list_of_footprints:
+ print( fp )
+
+elif len( sys.argv ) == 3:
+ # I had some concerns about back to back reads, this verifies it is no problem:
+ module = src_plugin.FootprintLoad( src_libpath, sys.argv[2] )
+ if not module:
+ print( "1st try: module", sys.argv[2], "not found" )
+ module = src_plugin.FootprintLoad( src_libpath, sys.argv[2] )
+ if not module:
+ print( "2nd try: module", sys.argv[2], "not found" )
+ print( module )
+
+