diff --git a/kinparse/kinparse.py b/kinparse/kinparse.py index f8db1de..5252c80 100644 --- a/kinparse/kinparse.py +++ b/kinparse/kinparse.py @@ -94,7 +94,7 @@ def _paren_clause(keyword, subclause): datasheet = _paren_clause('datasheet', anystring('datasheet')) field = Group(_paren_clause('field', name & anystring('value'))) fields = _paren_clause('fields', ZeroOrMore(field)('fields')) - property = _paren_clause('property', name & value) + property = Group(_paren_clause('property', name & value)) properties = OneOrMore(property)('properties') lib = _paren_clause('lib', anystring('lib')) part = _paren_clause('part', anystring('name')) diff --git a/tests/data/kicad5_test.net b/tests/data/kicad5_test.net new file mode 100644 index 0000000..b46ca1f --- /dev/null +++ b/tests/data/kicad5_test.net @@ -0,0 +1,98 @@ +(export (version D) + (design + (source /home/devb/tech_stuff/KiCad/tools/kinparse/tests/data/kicad5_test.sch) + (date "Tue 22 Mar 2022 05:12:36 PM EDT") + (tool "Eeschema 5.1.12-84ad8e8a86~92~ubuntu20.04.1") + (sheet (number 1) (name /) (tstamps /) + (title_block + (title "title") + (company "company") + (rev "1.0") + (date "03/23/2022") + (source kicad5_test.sch) + (comment (number 1) (value "")) + (comment (number 2) (value "")) + (comment (number 3) (value "")) + (comment (number 4) (value ""))))) + (components + (comp (ref Q1) + (value Q_NPN_CBE) + (datasheet ~) + (libsource (lib Device) (part Q_NPN_CBE) (description "NPN transistor, collector/base/emitter")) + (sheetpath (names /) (tstamps /)) + (tstamp 623A135E)) + (comp (ref R4) + (value R_US) + (datasheet ~) + (libsource (lib Device) (part R_US) (description "Resistor, US symbol")) + (sheetpath (names /) (tstamps /)) + (tstamp 623A1A21)) + (comp (ref R5) + (value R_US) + (datasheet ~) + (libsource (lib Device) (part R_US) (description "Resistor, US symbol")) + (sheetpath (names /) (tstamps /)) + (tstamp 623A2D4A)) + (comp (ref R2) + (value R_US) + (datasheet ~) + (libsource (lib Device) (part R_US) (description "Resistor, US symbol")) + (sheetpath (names /) (tstamps /)) + (tstamp 623A35E2)) + (comp (ref R3) + (value R_US) + (datasheet ~) + (libsource (lib Device) (part R_US) (description "Resistor, US symbol")) + (sheetpath (names /) (tstamps /)) + (tstamp 623A42C8)) + (comp (ref R1) + (value R_US) + (datasheet ~) + (libsource (lib Device) (part R_US) (description "Resistor, US symbol")) + (sheetpath (names /) (tstamps /)) + (tstamp 623A4BDC))) + (libparts + (libpart (lib Device) (part Q_NPN_CBE) + (description "NPN transistor, collector/base/emitter") + (docs ~) + (fields + (field (name Reference) Q) + (field (name Value) Q_NPN_CBE)) + (pins + (pin (num 1) (name C) (type passive)) + (pin (num 2) (name B) (type input)) + (pin (num 3) (name E) (type passive)))) + (libpart (lib Device) (part R_US) + (description "Resistor, US symbol") + (docs ~) + (footprints + (fp R_*)) + (fields + (field (name Reference) R) + (field (name Value) R_US)) + (pins + (pin (num 1) (name ~) (type passive)) + (pin (num 2) (name ~) (type passive))))) + (libraries + (library (logical Device) + (uri /usr/share/kicad/library/Device.lib))) + (nets + (net (code 1) (name "Net-(Q1-Pad2)") + (node (ref R1) (pin 1)) + (node (ref R3) (pin 1)) + (node (ref R2) (pin 2)) + (node (ref Q1) (pin 2))) + (net (code 2) (name "Net-(Q1-Pad3)") + (node (ref R5) (pin 1)) + (node (ref Q1) (pin 3))) + (net (code 3) (name GND) + (node (ref R3) (pin 2)) + (node (ref R5) (pin 2))) + (net (code 4) (name OUT) + (node (ref Q1) (pin 1)) + (node (ref R4) (pin 2))) + (net (code 5) (name IN) + (node (ref R1) (pin 2))) + (net (code 6) (name +5V) + (node (ref R4) (pin 1)) + (node (ref R2) (pin 1))))) \ No newline at end of file diff --git a/tests/data/kicad5_test.sch b/tests/data/kicad5_test.sch new file mode 100644 index 0000000..3527f50 --- /dev/null +++ b/tests/data/kicad5_test.sch @@ -0,0 +1,142 @@ +EESchema Schematic File Version 4 +EELAYER 30 0 +EELAYER END +$Descr A4 11693 8268 +encoding utf-8 +Sheet 1 1 +Title "" +Date "" +Rev "" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L Device:Q_NPN_CBE Q1 +U 1 1 623A135E +P 5500 3575 +F 0 "Q1" H 5691 3621 50 0000 L CNN +F 1 "Q_NPN_CBE" H 5691 3530 50 0000 L CNN +F 2 "" H 5700 3675 50 0001 C CNN +F 3 "~" H 5500 3575 50 0001 C CNN + 1 5500 3575 + 1 0 0 -1 +$EndComp +$Comp +L Device:R_US R4 +U 1 1 623A1A21 +P 5600 3100 +F 0 "R4" H 5668 3146 50 0000 L CNN +F 1 "R_US" H 5668 3055 50 0000 L CNN +F 2 "" V 5640 3090 50 0001 C CNN +F 3 "~" H 5600 3100 50 0001 C CNN + 1 5600 3100 + 1 0 0 -1 +$EndComp +$Comp +L Device:R_US R5 +U 1 1 623A2D4A +P 5600 4075 +F 0 "R5" H 5668 4121 50 0000 L CNN +F 1 "R_US" H 5668 4030 50 0000 L CNN +F 2 "" V 5640 4065 50 0001 C CNN +F 3 "~" H 5600 4075 50 0001 C CNN + 1 5600 4075 + 1 0 0 -1 +$EndComp +$Comp +L Device:R_US R2 +U 1 1 623A35E2 +P 5300 3100 +F 0 "R2" H 5368 3146 50 0000 L CNN +F 1 "R_US" H 5368 3055 50 0000 L CNN +F 2 "" V 5340 3090 50 0001 C CNN +F 3 "~" H 5300 3100 50 0001 C CNN + 1 5300 3100 + 1 0 0 -1 +$EndComp +$Comp +L Device:R_US R3 +U 1 1 623A42C8 +P 5300 4075 +F 0 "R3" H 5368 4121 50 0000 L CNN +F 1 "R_US" H 5368 4030 50 0000 L CNN +F 2 "" V 5340 4065 50 0001 C CNN +F 3 "~" H 5300 4075 50 0001 C CNN + 1 5300 4075 + 1 0 0 -1 +$EndComp +$Comp +L Device:R_US R1 +U 1 1 623A4BDC +P 4950 3575 +F 0 "R1" V 4745 3575 50 0000 C CNN +F 1 "R_US" V 4836 3575 50 0000 C CNN +F 2 "" V 4990 3565 50 0001 C CNN +F 3 "~" H 4950 3575 50 0001 C CNN + 1 4950 3575 + 0 1 1 0 +$EndComp +$Comp +L power:+5V #PWR0101 +U 1 1 623A5A79 +P 5600 2775 +F 0 "#PWR0101" H 5600 2625 50 0001 C CNN +F 1 "+5V" H 5615 2948 50 0000 C CNN +F 2 "" H 5600 2775 50 0001 C CNN +F 3 "" H 5600 2775 50 0001 C CNN + 1 5600 2775 + 1 0 0 -1 +$EndComp +$Comp +L power:GND #PWR0102 +U 1 1 623A63AA +P 5600 4450 +F 0 "#PWR0102" H 5600 4200 50 0001 C CNN +F 1 "GND" H 5605 4277 50 0000 C CNN +F 2 "" H 5600 4450 50 0001 C CNN +F 3 "" H 5600 4450 50 0001 C CNN + 1 5600 4450 + 1 0 0 -1 +$EndComp +Wire Wire Line + 5600 2775 5600 2850 +Wire Wire Line + 5600 3250 5600 3325 +Wire Wire Line + 5600 4225 5600 4325 +Wire Wire Line + 5600 3775 5600 3925 +Wire Wire Line + 5100 3575 5300 3575 +Wire Wire Line + 5600 2850 5300 2850 +Wire Wire Line + 5300 2850 5300 2950 +Wire Wire Line + 5300 4325 5600 4325 +Wire Wire Line + 5300 3250 5300 3575 +Wire Wire Line + 5300 4225 5300 4325 +Connection ~ 5600 2850 +Wire Wire Line + 5600 2850 5600 2950 +Connection ~ 5300 3575 +Wire Wire Line + 5300 3575 5300 3925 +Connection ~ 5600 4325 +Wire Wire Line + 5600 4325 5600 4450 +Text GLabel 4800 3575 0 50 Input ~ 0 +IN +Wire Wire Line + 5600 3325 5875 3325 +Connection ~ 5600 3325 +Wire Wire Line + 5600 3325 5600 3375 +Text GLabel 5875 3325 2 50 Output ~ 0 +OUT +$EndSCHEMATC diff --git a/tests/data/kicad6_test.kicad_sch b/tests/data/kicad6_test.kicad_sch new file mode 100644 index 0000000..dd7ee44 --- /dev/null +++ b/tests/data/kicad6_test.kicad_sch @@ -0,0 +1,509 @@ +(kicad_sch (version 20211123) (generator eeschema) + + (uuid e63e39d7-6ac0-4ffd-8aa3-1841a4541b55) + + (paper "A4") + + (lib_symbols + (symbol "Device:Q_NPN_CBE" (pin_names (offset 0) hide) (in_bom yes) (on_board yes) + (property "Reference" "Q" (id 0) (at 5.08 1.27 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Value" "Q_NPN_CBE" (id 1) (at 5.08 -1.27 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Footprint" "" (id 2) (at 5.08 2.54 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_keywords" "transistor NPN" (id 4) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_description" "NPN transistor, collector/base/emitter" (id 5) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (symbol "Q_NPN_CBE_0_1" + (polyline + (pts + (xy 0.635 0.635) + (xy 2.54 2.54) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0.635 -0.635) + (xy 2.54 -2.54) + (xy 2.54 -2.54) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0.635 1.905) + (xy 0.635 -1.905) + (xy 0.635 -1.905) + ) + (stroke (width 0.508) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 1.27 -1.778) + (xy 1.778 -1.27) + (xy 2.286 -2.286) + (xy 1.27 -1.778) + (xy 1.27 -1.778) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type outline)) + ) + (circle (center 1.27 0) (radius 2.8194) + (stroke (width 0.254) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + ) + (symbol "Q_NPN_CBE_1_1" + (pin passive line (at 2.54 5.08 270) (length 2.54) + (name "C" (effects (font (size 1.27 1.27)))) + (number "1" (effects (font (size 1.27 1.27)))) + ) + (pin input line (at -5.08 0 0) (length 5.715) + (name "B" (effects (font (size 1.27 1.27)))) + (number "2" (effects (font (size 1.27 1.27)))) + ) + (pin passive line (at 2.54 -5.08 90) (length 2.54) + (name "E" (effects (font (size 1.27 1.27)))) + (number "3" (effects (font (size 1.27 1.27)))) + ) + ) + ) + (symbol "Device:R_US" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes) + (property "Reference" "R" (id 0) (at 2.54 0 90) + (effects (font (size 1.27 1.27))) + ) + (property "Value" "R_US" (id 1) (at -2.54 0 90) + (effects (font (size 1.27 1.27))) + ) + (property "Footprint" "" (id 2) (at 1.016 -0.254 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_keywords" "R res resistor" (id 4) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_description" "Resistor, US symbol" (id 5) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_fp_filters" "R_*" (id 6) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (symbol "R_US_0_1" + (polyline + (pts + (xy 0 -2.286) + (xy 0 -2.54) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0 2.286) + (xy 0 2.54) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0 -0.762) + (xy 1.016 -1.143) + (xy 0 -1.524) + (xy -1.016 -1.905) + (xy 0 -2.286) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0 0.762) + (xy 1.016 0.381) + (xy 0 0) + (xy -1.016 -0.381) + (xy 0 -0.762) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0 2.286) + (xy 1.016 1.905) + (xy 0 1.524) + (xy -1.016 1.143) + (xy 0 0.762) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + ) + (symbol "R_US_1_1" + (pin passive line (at 0 3.81 270) (length 1.27) + (name "~" (effects (font (size 1.27 1.27)))) + (number "1" (effects (font (size 1.27 1.27)))) + ) + (pin passive line (at 0 -3.81 90) (length 1.27) + (name "~" (effects (font (size 1.27 1.27)))) + (number "2" (effects (font (size 1.27 1.27)))) + ) + ) + ) + (symbol "power:+5V" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes) + (property "Reference" "#PWR" (id 0) (at 0 -3.81 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Value" "+5V" (id 1) (at 0 3.556 0) + (effects (font (size 1.27 1.27))) + ) + (property "Footprint" "" (id 2) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "" (id 3) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_keywords" "power-flag" (id 4) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_description" "Power symbol creates a global label with name \"+5V\"" (id 5) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (symbol "+5V_0_1" + (polyline + (pts + (xy -0.762 1.27) + (xy 0 2.54) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0 0) + (xy 0 2.54) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + (polyline + (pts + (xy 0 2.54) + (xy 0.762 1.27) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + ) + (symbol "+5V_1_1" + (pin power_in line (at 0 0 90) (length 0) hide + (name "+5V" (effects (font (size 1.27 1.27)))) + (number "1" (effects (font (size 1.27 1.27)))) + ) + ) + ) + (symbol "power:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes) + (property "Reference" "#PWR" (id 0) (at 0 -6.35 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Value" "GND" (id 1) (at 0 -3.81 0) + (effects (font (size 1.27 1.27))) + ) + (property "Footprint" "" (id 2) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "" (id 3) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_keywords" "power-flag" (id 4) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "ki_description" "Power symbol creates a global label with name \"GND\" , ground" (id 5) (at 0 0 0) + (effects (font (size 1.27 1.27)) hide) + ) + (symbol "GND_0_1" + (polyline + (pts + (xy 0 0) + (xy 0 -1.27) + (xy 1.27 -1.27) + (xy 0 -2.54) + (xy -1.27 -1.27) + (xy 0 -1.27) + ) + (stroke (width 0) (type default) (color 0 0 0 0)) + (fill (type none)) + ) + ) + (symbol "GND_1_1" + (pin power_in line (at 0 0 270) (length 0) hide + (name "GND" (effects (font (size 1.27 1.27)))) + (number "1" (effects (font (size 1.27 1.27)))) + ) + ) + ) + ) + + (junction (at 134.62 83.82) (diameter 0) (color 0 0 0 0) + (uuid 22038e08-14cd-44e9-8610-24bfe8a0e2a4) + ) + (junction (at 127 96.52) (diameter 0) (color 0 0 0 0) + (uuid 33473488-6682-4cdf-8de3-5a3552a7ce88) + ) + (junction (at 134.62 91.44) (diameter 0) (color 0 0 0 0) + (uuid 3c24ab61-861f-414b-bf23-eb9f1d4e8369) + ) + (junction (at 134.62 110.49) (diameter 0) (color 0 0 0 0) + (uuid 9285293e-f7a3-4e01-ac88-9ebc0c104a54) + ) + + (wire (pts (xy 109.22 96.52) (xy 114.3 96.52)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 4a98e74f-1fb6-49e8-b8bb-ea48459ab3e0) + ) + (wire (pts (xy 127 91.44) (xy 127 96.52)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 51cd9e0a-6177-4d9c-98d7-9dbbb77f9cd5) + ) + (wire (pts (xy 121.92 96.52) (xy 127 96.52)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 527f3c91-95f0-4b0d-b126-85c3de1e0a0e) + ) + (wire (pts (xy 127 110.49) (xy 134.62 110.49)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 6f57bf78-2b34-4713-8e9c-fb4ef9834ffe) + ) + (wire (pts (xy 127 109.22) (xy 127 110.49)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 740f7dd3-51a1-4d1b-9613-7bb23278ddb7) + ) + (wire (pts (xy 134.62 110.49) (xy 134.62 114.3)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 742c855f-2291-400f-b4de-9233365de062) + ) + (wire (pts (xy 134.62 91.44) (xy 148.59 91.44)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 7dc39591-bc79-4a9b-95c0-417b27d600d5) + ) + (wire (pts (xy 134.62 78.74) (xy 134.62 83.82)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 90f46995-4dde-4fca-9045-b7cc5caea84e) + ) + (wire (pts (xy 134.62 109.22) (xy 134.62 110.49)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid 95b53bcc-b2b5-4fc8-9d4f-68b388576eee) + ) + (wire (pts (xy 127 83.82) (xy 134.62 83.82)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid a8f2dacf-2d5a-4a9a-849c-44c9324f121c) + ) + (wire (pts (xy 127 96.52) (xy 127 101.6)) + (stroke (width 0) (type default) (color 0 0 0 0)) + (uuid bd1609c1-9e92-4ee5-b01d-8d00f8dc62fa) + ) + + (global_label "OUT" (shape output) (at 148.59 91.44 0) (fields_autoplaced) + (effects (font (size 1.27 1.27)) (justify left)) + (uuid 96a5c046-2bb8-4223-addc-0967a661f4f5) + (property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 154.6317 91.3606 0) + (effects (font (size 1.27 1.27)) (justify left) hide) + ) + ) + (global_label "IN" (shape input) (at 109.22 96.52 180) (fields_autoplaced) + (effects (font (size 1.27 1.27)) (justify right)) + (uuid d4f7fae7-033b-42f6-b7ba-d553a4e26289) + (property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 104.8717 96.4406 0) + (effects (font (size 1.27 1.27)) (justify right) hide) + ) + ) + + (symbol (lib_id "Device:R_US") (at 118.11 96.52 90) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 0520cef8-5eb4-4ad6-9db3-e738a3afea43) + (property "Reference" "R1" (id 0) (at 118.11 90.17 90)) + (property "Value" "R_US" (id 1) (at 118.11 92.71 90)) + (property "Footprint" "" (id 2) (at 118.364 95.504 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 118.11 96.52 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid d0061db9-f957-4928-a91b-b0ddb72c8595)) + (pin "2" (uuid 61450f2e-b3c3-417f-9b70-0afa465cacbf)) + ) + + (symbol (lib_id "Device:Q_NPN_CBE") (at 132.08 96.52 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 08fae221-7b6f-4c57-be73-6210c6206091) + (property "Reference" "Q1" (id 0) (at 137.16 95.2499 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Value" "Q_NPN_CBE" (id 1) (at 137.16 97.7899 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Footprint" "" (id 2) (at 137.16 93.98 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 132.08 96.52 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid 6e9aab82-e6c0-4960-99af-e7c5a83d520f)) + (pin "2" (uuid db09a492-3111-4077-8b89-2ff4c8eebad3)) + (pin "3" (uuid 8f29ec2b-5253-4ae2-bf8f-40e83998f739)) + ) + + (symbol (lib_id "power:GND") (at 134.62 114.3 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 0f3541ed-d38f-4d54-87aa-efe15ec860fa) + (property "Reference" "#PWR02" (id 0) (at 134.62 120.65 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Value" "GND" (id 1) (at 134.62 119.38 0)) + (property "Footprint" "" (id 2) (at 134.62 114.3 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "" (id 3) (at 134.62 114.3 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid 535b76cd-fc12-4f09-acee-3d10d4fb3829)) + ) + + (symbol (lib_id "Device:R_US") (at 134.62 87.63 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 4be9bcff-98b2-46ca-809c-98605f99802f) + (property "Reference" "R4" (id 0) (at 137.16 86.3599 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Value" "R_US" (id 1) (at 137.16 88.8999 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Footprint" "" (id 2) (at 135.636 87.884 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 134.62 87.63 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid b0f67d00-898d-4d86-831c-879d20ea58d1)) + (pin "2" (uuid a83a46a9-63ee-4d26-bfce-0ba963092218)) + ) + + (symbol (lib_id "power:+5V") (at 134.62 78.74 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 51ddfd96-d047-4f81-9be8-fab6aa44eb92) + (property "Reference" "#PWR01" (id 0) (at 134.62 82.55 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Value" "+5V" (id 1) (at 134.62 73.66 0)) + (property "Footprint" "" (id 2) (at 134.62 78.74 0) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "" (id 3) (at 134.62 78.74 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid 999da873-64db-46ef-9afc-708c26450aaf)) + ) + + (symbol (lib_id "Device:R_US") (at 127 105.41 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 803be133-afda-4dfd-b6d5-104381910e3a) + (property "Reference" "R3" (id 0) (at 129.54 104.1399 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Value" "R_US" (id 1) (at 129.54 106.6799 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Footprint" "" (id 2) (at 128.016 105.664 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 127 105.41 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid bdde9e11-7801-483e-9088-385c57e7afa3)) + (pin "2" (uuid 639f8471-ada5-4f78-89f6-af541dfd2b3a)) + ) + + (symbol (lib_id "Device:R_US") (at 134.62 105.41 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid 9c27bafe-dc9a-4fc8-9304-3713da742e75) + (property "Reference" "R5" (id 0) (at 137.16 104.1399 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Value" "R_US" (id 1) (at 137.16 106.6799 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Footprint" "" (id 2) (at 135.636 105.664 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 134.62 105.41 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid 8caa6ac8-9324-4dbf-9999-0ab7579656ee)) + (pin "2" (uuid 962defff-51d6-4ea0-9a4d-3205cf1d6dd3)) + ) + + (symbol (lib_id "Device:R_US") (at 127 87.63 0) (unit 1) + (in_bom yes) (on_board yes) (fields_autoplaced) + (uuid dfe7aa15-3d3f-4a25-935c-577ae609d381) + (property "Reference" "R2" (id 0) (at 129.54 86.3599 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Value" "R_US" (id 1) (at 129.54 88.8999 0) + (effects (font (size 1.27 1.27)) (justify left)) + ) + (property "Footprint" "" (id 2) (at 128.016 87.884 90) + (effects (font (size 1.27 1.27)) hide) + ) + (property "Datasheet" "~" (id 3) (at 127 87.63 0) + (effects (font (size 1.27 1.27)) hide) + ) + (pin "1" (uuid 02cfcace-e3c9-4ff8-9a7d-8c9ddff38412)) + (pin "2" (uuid 18e0d667-71c2-4288-ab78-9b784fe175c7)) + ) + + (sheet_instances + (path "/" (page "1")) + ) + + (symbol_instances + (path "/51ddfd96-d047-4f81-9be8-fab6aa44eb92" + (reference "#PWR01") (unit 1) (value "+5V") (footprint "") + ) + (path "/0f3541ed-d38f-4d54-87aa-efe15ec860fa" + (reference "#PWR02") (unit 1) (value "GND") (footprint "") + ) + (path "/08fae221-7b6f-4c57-be73-6210c6206091" + (reference "Q1") (unit 1) (value "Q_NPN_CBE") (footprint "") + ) + (path "/0520cef8-5eb4-4ad6-9db3-e738a3afea43" + (reference "R1") (unit 1) (value "R_US") (footprint "") + ) + (path "/dfe7aa15-3d3f-4a25-935c-577ae609d381" + (reference "R2") (unit 1) (value "R_US") (footprint "") + ) + (path "/803be133-afda-4dfd-b6d5-104381910e3a" + (reference "R3") (unit 1) (value "R_US") (footprint "") + ) + (path "/4be9bcff-98b2-46ca-809c-98605f99802f" + (reference "R4") (unit 1) (value "R_US") (footprint "") + ) + (path "/9c27bafe-dc9a-4fc8-9304-3713da742e75" + (reference "R5") (unit 1) (value "R_US") (footprint "") + ) + ) +) diff --git a/tests/data/kicad6_test.net b/tests/data/kicad6_test.net index ac53d74..e3c187b 100644 --- a/tests/data/kicad6_test.net +++ b/tests/data/kicad6_test.net @@ -1,15 +1,15 @@ (export (version "E") (design - (source "/media/devb/Main/TEMP/kicad6_projects/netlist_test/netlist_test.kicad_sch") - (date "Wed 16 Feb 2022 03:07:47 PM EST") - (tool "Eeschema 6.0.2-378541a8eb~116~ubuntu20.04.1") + (source "/home/devb/tech_stuff/KiCad/tools/kinparse/tests/data/kicad6_test_2.kicad_sch") + (date "Tue 22 Mar 2022 05:06:15 PM EDT") + (tool "Eeschema 6.0.0-d3dd2cf0fa~116~ubuntu20.04.1") (sheet (number "1") (name "/") (tstamps "/") (title_block - (title "test title") - (company "XESS Corp.") - (rev 1) - (date 2022-02-17) - (source "netlist_test.kicad_sch") + (title "title") + (company "company") + (rev "1.0") + (date "03/23/2022") + (source "kicad6_test_2.kicad_sch") (comment (number "1") (value "")) (comment (number "2") (value "")) (comment (number "3") (value "")) @@ -20,70 +20,98 @@ (comment (number "8") (value "")) (comment (number "9") (value ""))))) (components - (comp (ref "U1") - (value "LM318J") - (footprint "Package_DIP:DIP-14_W7.62mm") - (datasheet "http://www.ti.com/lit/ds/symlink/lm318-n.pdf") - (libsource (lib "Amplifier_Operational") (part "LM318J") (description "Operational Amplifier, DIP-14")) + (comp (ref "Q1") + (value "Q_NPN_CBE") + (datasheet "~") + (libsource (lib "Device") (part "Q_NPN_CBE") (description "NPN transistor, collector/base/emitter")) (property (name "Sheetname") (value "")) - (property (name "Sheetfile") (value "netlist_test.kicad_sch")) + (property (name "Sheetfile") (value "kicad6_test_2.kicad_sch")) (sheetpath (names "/") (tstamps "/")) - (tstamps "e0660a46-ff2a-4b28-b311-cf71bc999b82"))) + (tstamps "08fae221-7b6f-4c57-be73-6210c6206091")) + (comp (ref "R1") + (value "R_US") + (datasheet "~") + (libsource (lib "Device") (part "R_US") (description "Resistor, US symbol")) + (property (name "Sheetname") (value "")) + (property (name "Sheetfile") (value "kicad6_test_2.kicad_sch")) + (sheetpath (names "/") (tstamps "/")) + (tstamps "0520cef8-5eb4-4ad6-9db3-e738a3afea43")) + (comp (ref "R2") + (value "R_US") + (datasheet "~") + (libsource (lib "Device") (part "R_US") (description "Resistor, US symbol")) + (property (name "Sheetname") (value "")) + (property (name "Sheetfile") (value "kicad6_test_2.kicad_sch")) + (sheetpath (names "/") (tstamps "/")) + (tstamps "dfe7aa15-3d3f-4a25-935c-577ae609d381")) + (comp (ref "R3") + (value "R_US") + (datasheet "~") + (libsource (lib "Device") (part "R_US") (description "Resistor, US symbol")) + (property (name "Sheetname") (value "")) + (property (name "Sheetfile") (value "kicad6_test_2.kicad_sch")) + (sheetpath (names "/") (tstamps "/")) + (tstamps "803be133-afda-4dfd-b6d5-104381910e3a")) + (comp (ref "R4") + (value "R_US") + (datasheet "~") + (libsource (lib "Device") (part "R_US") (description "Resistor, US symbol")) + (property (name "Sheetname") (value "")) + (property (name "Sheetfile") (value "kicad6_test_2.kicad_sch")) + (sheetpath (names "/") (tstamps "/")) + (tstamps "4be9bcff-98b2-46ca-809c-98605f99802f")) + (comp (ref "R5") + (value "R_US") + (datasheet "~") + (libsource (lib "Device") (part "R_US") (description "Resistor, US symbol")) + (property (name "Sheetname") (value "")) + (property (name "Sheetfile") (value "kicad6_test_2.kicad_sch")) + (sheetpath (names "/") (tstamps "/")) + (tstamps "9c27bafe-dc9a-4fc8-9304-3713da742e75"))) (libparts - (libpart (lib "Amplifier_Operational") (part "LM318J") - (description "Operational Amplifier, DIP-14") - (docs "http://www.ti.com/lit/ds/symlink/lm318-n.pdf") + (libpart (lib "Device") (part "Q_NPN_CBE") + (description "NPN transistor, collector/base/emitter") + (docs "~") + (fields + (field (name "Reference") "Q") + (field (name "Value") "Q_NPN_CBE") + (field (name "Datasheet") "~")) + (pins + (pin (num "1") (name "C") (type "passive")) + (pin (num "2") (name "B") (type "input")) + (pin (num "3") (name "E") (type "passive")))) + (libpart (lib "Device") (part "R_US") + (description "Resistor, US symbol") + (docs "~") (footprints - (fp "DIP*W7.62mm*")) + (fp "R_*")) (fields - (field (name "Reference") "U") - (field (name "Value") "LM318J") - (field (name "Footprint") "Package_DIP:DIP-14_W7.62mm") - (field (name "Datasheet") "http://www.ti.com/lit/ds/symlink/lm318-n.pdf")) + (field (name "Reference") "R") + (field (name "Value") "R_US") + (field (name "Datasheet") "~")) (pins - (pin (num "1") (name "NC") (type "no_connect")) - (pin (num "2") (name "NC") (type "no_connect")) - (pin (num "3") (name "BAL1") (type "passive")) - (pin (num "4") (name "-") (type "input")) - (pin (num "5") (name "+") (type "input")) - (pin (num "6") (name "V-") (type "power_in")) - (pin (num "7") (name "NC") (type "no_connect")) - (pin (num "8") (name "NC") (type "no_connect")) - (pin (num "9") (name "BAL3") (type "passive")) - (pin (num "10") (name "") (type "output")) - (pin (num "11") (name "V+") (type "power_in")) - (pin (num "12") (name "BAL2") (type "passive")) - (pin (num "13") (name "NC") (type "no_connect")) - (pin (num "14") (name "NC") (type "no_connect"))))) + (pin (num "1") (name "") (type "passive")) + (pin (num "2") (name "") (type "passive"))))) (libraries - (library (logical "Amplifier_Operational") - (uri "/usr/share/kicad/symbols/Amplifier_Operational.kicad_sym"))) + (library (logical "Device") + (uri "/usr/share/kicad/symbols//Device.kicad_sym"))) (nets (net (code "1") (name "+5V") - (node (ref "U1") (pin "11") (pinfunction "V+") (pintype "power_in"))) + (node (ref "R2") (pin "1") (pintype "passive")) + (node (ref "R4") (pin "1") (pintype "passive"))) (net (code "2") (name "GND") - (node (ref "U1") (pin "6") (pinfunction "V-") (pintype "power_in"))) - (net (code "3") (name "unconnected-(U1-Pad1)") - (node (ref "U1") (pin "1") (pinfunction "NC") (pintype "no_connect"))) - (net (code "4") (name "unconnected-(U1-Pad2)") - (node (ref "U1") (pin "2") (pinfunction "NC") (pintype "no_connect"))) - (net (code "5") (name "unconnected-(U1-Pad3)") - (node (ref "U1") (pin "3") (pinfunction "BAL1") (pintype "passive"))) - (net (code "6") (name "unconnected-(U1-Pad4)") - (node (ref "U1") (pin "4") (pinfunction "-") (pintype "input"))) - (net (code "7") (name "unconnected-(U1-Pad5)") - (node (ref "U1") (pin "5") (pinfunction "+") (pintype "input"))) - (net (code "8") (name "unconnected-(U1-Pad7)") - (node (ref "U1") (pin "7") (pinfunction "NC") (pintype "no_connect"))) - (net (code "9") (name "unconnected-(U1-Pad8)") - (node (ref "U1") (pin "8") (pinfunction "NC") (pintype "no_connect"))) - (net (code "10") (name "unconnected-(U1-Pad9)") - (node (ref "U1") (pin "9") (pinfunction "BAL3") (pintype "passive"))) - (net (code "11") (name "unconnected-(U1-Pad10)") - (node (ref "U1") (pin "10") (pintype "output"))) - (net (code "12") (name "unconnected-(U1-Pad12)") - (node (ref "U1") (pin "12") (pinfunction "BAL2") (pintype "passive"))) - (net (code "13") (name "unconnected-(U1-Pad13)") - (node (ref "U1") (pin "13") (pinfunction "NC") (pintype "no_connect"))) - (net (code "14") (name "unconnected-(U1-Pad14)") - (node (ref "U1") (pin "14") (pinfunction "NC") (pintype "no_connect"))))) \ No newline at end of file + (node (ref "R3") (pin "2") (pintype "passive")) + (node (ref "R5") (pin "2") (pintype "passive"))) + (net (code "3") (name "IN") + (node (ref "R1") (pin "1") (pintype "passive"))) + (net (code "4") (name "Net-(R1-Pad2)") + (node (ref "Q1") (pin "2") (pinfunction "B") (pintype "input")) + (node (ref "R1") (pin "2") (pintype "passive")) + (node (ref "R2") (pin "2") (pintype "passive")) + (node (ref "R3") (pin "1") (pintype "passive"))) + (net (code "5") (name "Net-(R5-Pad1)") + (node (ref "Q1") (pin "3") (pinfunction "E") (pintype "passive")) + (node (ref "R5") (pin "1") (pintype "passive"))) + (net (code "6") (name "OUT") + (node (ref "Q1") (pin "1") (pinfunction "C") (pintype "passive")) + (node (ref "R4") (pin "2") (pintype "passive"))))) \ No newline at end of file diff --git a/tests/test_kinparse.py b/tests/test_kinparse.py index 572ca68..fc98e00 100644 --- a/tests/test_kinparse.py +++ b/tests/test_kinparse.py @@ -4,7 +4,7 @@ def isstr(s): print(s) - assert(isinstance(s, (type(u"A"), type("A"), type("")))) + assert isinstance(s, (type(u"A"), type("A"), type(""))) def parser_tests(ntlst): isstr(ntlst.version) @@ -77,14 +77,19 @@ def test_kinparse_3(): def test_kinparse_4(): ntlst = parse_netlist('data/gaillard.net') - assert(ntlst.parts[0].sheetpath.names == "/Logic/") - assert(ntlst.parts[0].sheetpath.tstamps == "/5C4D0F9E/") - assert(ntlst.parts[0].tstamp == "5C4D541F") + assert ntlst.parts[0].sheetpath.names == "/Logic/" + assert ntlst.parts[0].sheetpath.tstamps == "/5C4D0F9E/" + assert ntlst.parts[0].tstamp == "5C4D541F" parser_tests(ntlst) def test_kinparse_5(): + ntlst = parse_netlist('data/kicad5_test.net') + assert len(ntlst.parts) == 6 + assert len(ntlst.nets) == 6 + parser_tests(ntlst) + +def test_kinparse_6(): ntlst = parse_netlist('data/kicad6_test.net') - # assert(ntlst.parts[0].sheetpath.names == "/Logic/") - # assert(ntlst.parts[0].sheetpath.tstamps == "/5C4D0F9E/") - # assert(ntlst.parts[0].tstamp == "5C4D541F") + assert len(ntlst.parts) == 6 + assert len(ntlst.nets) == 6 parser_tests(ntlst)