From 68461cc1a156bf0b137a697fd70e8ca5f1f9a1af Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:34:31 +0100 Subject: [PATCH 1/8] Tests: Adding tests for image layer token --- tests/test_board.py | 7 +++++ tests/test_footprint.py | 7 +++++ .../board/since_v7/test_imageWithLayerToken | 28 +++++++++++++++++++ .../since_v7/test_imageWithLayerToken | 27 ++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 tests/testdata/board/since_v7/test_imageWithLayerToken create mode 100644 tests/testdata/footprint/since_v7/test_imageWithLayerToken diff --git a/tests/test_board.py b/tests/test_board.py index 0d32104..ab73bb6 100644 --- a/tests/test_board.py +++ b/tests/test_board.py @@ -97,4 +97,11 @@ def test_textBoxAllVariants(self): self.testData.compareToTestFile = True self.testData.pathToTestFile = path.join(BOARD_BASE, 'since_v7', 'test_textBoxAllVariants') board = Board().from_file(self.testData.pathToTestFile) + self.assertTrue(to_file_and_compare(board, self.testData)) + + def test_imageWithLayerToken(self): + """Tests the new ``layer`` token for images in PCBs""" + self.testData.compareToTestFile = True + self.testData.pathToTestFile = path.join(BOARD_BASE, 'since_v7', 'test_imageWithLayerToken') + board = Board().from_file(self.testData.pathToTestFile) self.assertTrue(to_file_and_compare(board, self.testData)) \ No newline at end of file diff --git a/tests/test_footprint.py b/tests/test_footprint.py index b8b2813..24c293c 100644 --- a/tests/test_footprint.py +++ b/tests/test_footprint.py @@ -109,4 +109,11 @@ def test_textBoxAllVariants(self): self.testData.compareToTestFile = True self.testData.pathToTestFile = path.join(FOOTPRINT_BASE, 'since_v7', 'test_textBoxAllVariants') footprint = Footprint().from_file(self.testData.pathToTestFile) + self.assertTrue(to_file_and_compare(footprint, self.testData)) + + def test_imageWithLayerToken(self): + """Tests the new ``layer`` token for images in footprints""" + self.testData.compareToTestFile = True + self.testData.pathToTestFile = path.join(FOOTPRINT_BASE, 'since_v7', 'test_imageWithLayerToken') + footprint = Footprint().from_file(self.testData.pathToTestFile) self.assertTrue(to_file_and_compare(footprint, self.testData)) \ No newline at end of file diff --git a/tests/testdata/board/since_v7/test_imageWithLayerToken b/tests/testdata/board/since_v7/test_imageWithLayerToken new file mode 100644 index 0000000..2a68bd5 --- /dev/null +++ b/tests/testdata/board/since_v7/test_imageWithLayerToken @@ -0,0 +1,28 @@ +(kicad_pcb (version 20221018) (generator kiutils) + + (general + (thickness 1.6) + ) + + (paper "A4") + (layers + (0 "F.Cu" signal) + ) + + (setup + (pad_to_mask_clearance 0) + ) + + (net 0 "") + + (image (at 203.2 99.06) (layer "F.Cu") + (data + iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAIAAAC0Ujn1AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA + AA50AAAOdAFrJLPWAAAA9ElEQVRIiWP88OEDA20AE43MHbJGs+CX1pp4hUiDruXroIkMzQAZmkYT + iEZMIMHDWmEvaS3P8/33v1NPvvYfffH002+sKhnx50a0FCLBw7o+WoWfg5kYR5Dm6go7SX4O5kuX + Li1atIiRkTEuLk5XV5c6Rlsr8DAwMCxevBji14kTJ8Kl5syZg6aYXtFIMO+dePTFWZkvLi5u0aJF + DAwM8fHxOjromRAOUKKRoNGKguzLw5X42GkQjfff/wxYcqfcTsJanvf777+nnnydcOwlJPFhliEk + p+sXX34XbntMjMqhmdFHjaaf0QRKPkrA0AyQUaPRAACmk1AZ+UHU4QAAAABJRU5ErkJggg== + ) + ) +) diff --git a/tests/testdata/footprint/since_v7/test_imageWithLayerToken b/tests/testdata/footprint/since_v7/test_imageWithLayerToken new file mode 100644 index 0000000..acff3a3 --- /dev/null +++ b/tests/testdata/footprint/since_v7/test_imageWithLayerToken @@ -0,0 +1,27 @@ +(footprint "image_test" (version 20221018) (generator kiutils) + (layer "F.Cu") + (tedit 640a506b) + (attr smd) + (fp_text reference "REF**" (at 0 -0.5 unlocked) (layer "F.SilkS") + (effects (font (size 1 1) (thickness 0.1))) + (tstamp 8fee236d-a937-47a4-b037-5b1ec0ea729a) + ) + (fp_text value "image_test" (at 0 1 unlocked) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp aeb0c71a-d788-467d-a13c-49ed75f3dbdb) + ) + (image (at 5.08 -7.62) (layer "F.SilkS") + (data + iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAIAAAC0Ujn1AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA + AA50AAAOdAFrJLPWAAAA9ElEQVRIiWP88OEDA20AE43MHbJGs+CX1pp4hUiDruXroIkMzQAZmkYT + iEZMIMHDWmEvaS3P8/33v1NPvvYfffH002+sKhnx50a0FCLBw7o+WoWfg5kYR5Dm6go7SX4O5kuX + Li1atIiRkTEuLk5XV5c6Rlsr8DAwMCxevBji14kTJ8Kl5syZg6aYXtFIMO+dePTFWZkvLi5u0aJF + DAwM8fHxOjromRAOUKKRoNGKguzLw5X42GkQjfff/wxYcqfcTsJanvf777+nnnydcOwlJPFhliEk + p+sXX34XbntMjMqhmdFHjaaf0QRKPkrA0AyQUaPRAACmk1AZ+UHU4QAAAABJRU5ErkJggg== + ) + ) + (fp_text user "${REFERENCE}" (at 0 2.5 unlocked) (layer "F.Fab") + (effects (font (size 1 1) (thickness 0.15))) + (tstamp a5217a7a-3aed-4722-8474-750c47ad16eb) + ) +) From 566e10aaed777f8fd6c7ac82518d51c3ab54014c Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:50:55 +0100 Subject: [PATCH 2/8] Items/*: Moved image token to common items --- src/kiutils/items/common.py | 76 +++++++++++++++++++++++++++++++++++ src/kiutils/items/schitems.py | 76 ----------------------------------- 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/kiutils/items/common.py b/src/kiutils/items/common.py index 72ebe0d..ab9fbdb 100644 --- a/src/kiutils/items/common.py +++ b/src/kiutils/items/common.py @@ -1067,3 +1067,79 @@ def to_sexpr(self, indent: int = 4, newline: bool = True) -> str: expression = f'{indents}(fill (type {self.type}){color}){endline}' return expression + +@dataclass +class Image(): + """The ``image`` token defines an image embedded into the file + + Documentation: + https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_image_section + """ + + position: Position = field(default_factory=lambda: Position()) + """The ``position`` defines the X and Y coordinates of the image""" + + scale: Optional[float] = None + """The optional ``scale`` token attribute defines the scale factor (size) of the image""" + + data: List[str] = field(default_factory=list) + """The ``data`` token attribute defines the image data in the portable network graphics + format (PNG) encoded with MIME type base64 as a list of strings""" + + uuid: Optional[str] = None + """The optional ``uuid`` defines the universally unique identifier. Defaults to ``None.``""" + + @classmethod + def from_sexpr(cls, exp: list) -> Image: + """Convert the given S-Expresstion into a Image object + + Args: + - exp (list): Part of parsed S-Expression ``(image ...)`` + + Raises: + - Exception: When given parameter's type is not a list + - Exception: When the first item of the list is not image + + Returns: + - Image: Object of the class initialized with the given S-Expression + """ + if not isinstance(exp, list): + raise Exception("Expression does not have the correct type") + + if exp[0] != 'image': + raise Exception("Expression does not have the correct type") + + object = cls() + for item in exp: + if item[0] == 'at': object.position = Position().from_sexpr(item) + if item[0] == 'scale': object.scale = item[1] + if item[0] == 'uuid': object.uuid = item[1] + if item[0] == 'data': + for b64part in item[1:]: + object.data.append(b64part) + return object + + def to_sexpr(self, indent=2, newline=True) -> str: + """Generate the S-Expression representing this object + + Args: + - indent (int): Number of whitespaces used to indent the output. Defaults to 2. + - newline (bool): Adds a newline to the end of the output. Defaults to True. + + Returns: + - str: S-Expression of this object + """ + indents = ' '*indent + endline = '\n' if newline else '' + + scale = f' (scale {self.scale})' if self.scale is not None else '' + + expression = f'{indents}(image (at {self.position.X} {self.position.Y}){scale}\n' + if self.uuid is not None: + expression += f'{indents} (uuid {self.uuid})\n' + expression += f'{indents} (data\n' + for b64part in self.data: + expression += f'{indents} {b64part}\n' + expression += f'{indents} )\n' + expression += f'{indents}){endline}' + return expression diff --git a/src/kiutils/items/schitems.py b/src/kiutils/items/schitems.py index 8988c4a..a07ae32 100644 --- a/src/kiutils/items/schitems.py +++ b/src/kiutils/items/schitems.py @@ -288,82 +288,6 @@ def to_sexpr(self, indent=2, newline=True) -> str: expression += f'{indents}){endline}' return expression -@dataclass -class Image(): - """The ``image`` token defines on or more embedded images in a schematic - - Documentation: - https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_image_section - """ - - position: Position = field(default_factory=lambda: Position()) - """The ``position`` defines the X and Y coordinates of the image""" - - scale: Optional[float] = None - """The optional ``scale`` token attribute defines the scale factor (size) of the image""" - - data: List[str] = field(default_factory=list) - """The ``data`` token attribute defines the image data in the portable network graphics - format (PNG) encoded with MIME type base64 as a list of strings""" - - uuid: Optional[str] = None - """The optional ``uuid`` defines the universally unique identifier. Defaults to ``None.``""" - - @classmethod - def from_sexpr(cls, exp: list) -> Image: - """Convert the given S-Expresstion into a Image object - - Args: - - exp (list): Part of parsed S-Expression ``(image ...)`` - - Raises: - - Exception: When given parameter's type is not a list - - Exception: When the first item of the list is not image - - Returns: - - Image: Object of the class initialized with the given S-Expression - """ - if not isinstance(exp, list): - raise Exception("Expression does not have the correct type") - - if exp[0] != 'image': - raise Exception("Expression does not have the correct type") - - object = cls() - for item in exp: - if item[0] == 'at': object.position = Position().from_sexpr(item) - if item[0] == 'scale': object.scale = item[1] - if item[0] == 'uuid': object.uuid = item[1] - if item[0] == 'data': - for b64part in item[1:]: - object.data.append(b64part) - return object - - def to_sexpr(self, indent=2, newline=True) -> str: - """Generate the S-Expression representing this object - - Args: - - indent (int): Number of whitespaces used to indent the output. Defaults to 2. - - newline (bool): Adds a newline to the end of the output. Defaults to True. - - Returns: - - str: S-Expression of this object - """ - indents = ' '*indent - endline = '\n' if newline else '' - - scale = f' (scale {self.scale})' if self.scale is not None else '' - - expression = f'{indents}(image (at {self.position.X} {self.position.Y}){scale}\n' - if self.uuid is not None: - expression += f'{indents} (uuid {self.uuid})\n' - expression += f'{indents} (data\n' - for b64part in self.data: - expression += f'{indents} {b64part}\n' - expression += f'{indents} )\n' - expression += f'{indents}){endline}' - return expression - @dataclass class PolyLine(): """The ``polyline`` token defines one or more lines that may or may not represent a polygon From c6bb5d295c7d6e843258d68020bdfa1a25a3d919 Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:51:38 +0100 Subject: [PATCH 3/8] Schematic: Reimported image token --- src/kiutils/schematic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kiutils/schematic.py b/src/kiutils/schematic.py index 529264c..40d65a8 100644 --- a/src/kiutils/schematic.py +++ b/src/kiutils/schematic.py @@ -19,7 +19,7 @@ from typing import Optional, List, Union from os import path -from kiutils.items.common import PageSettings, TitleBlock +from kiutils.items.common import Image, PageSettings, TitleBlock from kiutils.items.schitems import * from kiutils.symbol import Symbol from kiutils.utils import sexpr From 5114d8474b822690718e8abcd9612671221a28db Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 21:55:02 +0100 Subject: [PATCH 4/8] Tests: Added scale token to */since_v7/test_imageWithLayerToken --- tests/testdata/board/since_v7/test_imageWithLayerToken | 2 +- tests/testdata/footprint/since_v7/test_imageWithLayerToken | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testdata/board/since_v7/test_imageWithLayerToken b/tests/testdata/board/since_v7/test_imageWithLayerToken index 2a68bd5..f049297 100644 --- a/tests/testdata/board/since_v7/test_imageWithLayerToken +++ b/tests/testdata/board/since_v7/test_imageWithLayerToken @@ -15,7 +15,7 @@ (net 0 "") - (image (at 203.2 99.06) (layer "F.Cu") + (image (at 203.2 99.06) (layer "F.Cu") (scale 7.875) (data iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAIAAAC0Ujn1AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA AA50AAAOdAFrJLPWAAAA9ElEQVRIiWP88OEDA20AE43MHbJGs+CX1pp4hUiDruXroIkMzQAZmkYT diff --git a/tests/testdata/footprint/since_v7/test_imageWithLayerToken b/tests/testdata/footprint/since_v7/test_imageWithLayerToken index acff3a3..094e3a0 100644 --- a/tests/testdata/footprint/since_v7/test_imageWithLayerToken +++ b/tests/testdata/footprint/since_v7/test_imageWithLayerToken @@ -10,7 +10,7 @@ (effects (font (size 1 1) (thickness 0.15))) (tstamp aeb0c71a-d788-467d-a13c-49ed75f3dbdb) ) - (image (at 5.08 -7.62) (layer "F.SilkS") + (image (at 5.08 -7.62) (layer "F.SilkS") (scale 7.875) (data iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAIAAAC0Ujn1AAAAA3NCSVQICAjb4U/gAAAACXBIWXMA AA50AAAOdAFrJLPWAAAA9ElEQVRIiWP88OEDA20AE43MHbJGs+CX1pp4hUiDruXroIkMzQAZmkYT From 15d676387c9f140cf9afe3c5c4e733e4337b54a7 Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:04:47 +0100 Subject: [PATCH 5/8] Items/Common: Added layer token to Image --- src/kiutils/items/common.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/kiutils/items/common.py b/src/kiutils/items/common.py index ab9fbdb..3cfc450 100644 --- a/src/kiutils/items/common.py +++ b/src/kiutils/items/common.py @@ -1089,6 +1089,10 @@ class Image(): uuid: Optional[str] = None """The optional ``uuid`` defines the universally unique identifier. Defaults to ``None.``""" + layer: Optional[str] = None + """The optional ``layer`` token defines the canonical layer name when the image is used inside + a footprint or PCB. When used inside a schematic, this token is required to be ``None``.""" + @classmethod def from_sexpr(cls, exp: list) -> Image: """Convert the given S-Expresstion into a Image object @@ -1114,6 +1118,7 @@ def from_sexpr(cls, exp: list) -> Image: if item[0] == 'at': object.position = Position().from_sexpr(item) if item[0] == 'scale': object.scale = item[1] if item[0] == 'uuid': object.uuid = item[1] + if item[0] == 'layer': object.layer = item[1] if item[0] == 'data': for b64part in item[1:]: object.data.append(b64part) @@ -1133,8 +1138,9 @@ def to_sexpr(self, indent=2, newline=True) -> str: endline = '\n' if newline else '' scale = f' (scale {self.scale})' if self.scale is not None else '' + layer = f' (layer "{dequote(self.layer)}")' if self.layer is not None else '' - expression = f'{indents}(image (at {self.position.X} {self.position.Y}){scale}\n' + expression = f'{indents}(image (at {self.position.X} {self.position.Y}){layer}{scale}\n' if self.uuid is not None: expression += f'{indents} (uuid {self.uuid})\n' expression += f'{indents} (data\n' From c7aaa5d24c0c3d57f3474ea51709bd3f51377599 Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:05:31 +0100 Subject: [PATCH 6/8] Board: Added image token, (!) renamed graphicalItems -> graphicItems (!) --- src/kiutils/board.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/kiutils/board.py b/src/kiutils/board.py index d1a13f3..95f0959 100644 --- a/src/kiutils/board.py +++ b/src/kiutils/board.py @@ -19,7 +19,7 @@ from typing import Optional, List, Dict from os import path -from kiutils.items.common import Group, Net, PageSettings, TitleBlock +from kiutils.items.common import Group, Image, Net, PageSettings, TitleBlock from kiutils.items.zones import Zone from kiutils.items.brditems import * from kiutils.items.gritems import * @@ -67,9 +67,12 @@ class Board(): footprints: List[Footprint] = field(default_factory=list) """The ``footprints`` token defines a list of footprints used in the layout""" - graphicalItems: List = field(default_factory=list) # as in gritems.py - """The ``graphicalItems`` token defines a list of graphical items (as listed in `gritems.py`) used - in the layout""" + # TODO: Type hinting for this list + graphicItems: List = field(default_factory=list) # as in gritems.py + """The ``graphicItems`` token defines a list of graphical items used in the layout. Possible + tokens are found in ``kiutils.items.gritems`` + + The ``Image`` token is supported since KiCad v7 and must be added into this list when used.""" traceItems: List = field(default_factory=list) """The ``traceItems`` token defines a list of segments, arcs and vias used in the layout""" @@ -124,14 +127,15 @@ def from_sexpr(cls, exp: list) -> Board: if item[0] == 'property': object.properties.update({item[1]: item[2]}) if item[0] == 'net': object.nets.append(Net().from_sexpr(item)) if item[0] == 'footprint': object.footprints.append(Footprint().from_sexpr(item)) - if item[0] == 'gr_text': object.graphicalItems.append(GrText().from_sexpr(item)) - if item[0] == 'gr_text_box': object.graphicalItems.append(GrTextBox().from_sexpr(item)) - if item[0] == 'gr_line': object.graphicalItems.append(GrLine().from_sexpr(item)) - if item[0] == 'gr_rect': object.graphicalItems.append(GrRect().from_sexpr(item)) - if item[0] == 'gr_circle': object.graphicalItems.append(GrCircle().from_sexpr(item)) - if item[0] == 'gr_arc': object.graphicalItems.append(GrArc().from_sexpr(item)) - if item[0] == 'gr_poly': object.graphicalItems.append(GrPoly().from_sexpr(item)) - if item[0] == 'gr_curve': object.graphicalItems.append(GrCurve().from_sexpr(item)) + if item[0] == 'gr_text': object.graphicItems.append(GrText().from_sexpr(item)) + if item[0] == 'gr_text_box': object.graphicItems.append(GrTextBox().from_sexpr(item)) + if item[0] == 'gr_line': object.graphicItems.append(GrLine().from_sexpr(item)) + if item[0] == 'gr_rect': object.graphicItems.append(GrRect().from_sexpr(item)) + if item[0] == 'gr_circle': object.graphicItems.append(GrCircle().from_sexpr(item)) + if item[0] == 'gr_arc': object.graphicItems.append(GrArc().from_sexpr(item)) + if item[0] == 'gr_poly': object.graphicItems.append(GrPoly().from_sexpr(item)) + if item[0] == 'gr_curve': object.graphicItems.append(GrCurve().from_sexpr(item)) + if item[0] == 'image': object.graphicItems.append(Image().from_sexpr(item)) if item[0] == 'dimension': object.dimensions.append(Dimension().from_sexpr(item)) if item[0] == 'target': object.targets.append(Target().from_sexpr(item)) if item[0] == 'segment': object.traceItems.append(Segment().from_sexpr(item)) @@ -278,9 +282,9 @@ def to_sexpr(self, indent=0, newline=True) -> str: expression += footprint.to_sexpr(indent+2, layerInFirstLine=True) + '\n' # Lines, Texts, Arcs and other graphical items - if len(self.graphicalItems) > 0: + if len(self.graphicItems) > 0: addNewLine = True - for item in self.graphicalItems: + for item in self.graphicItems: if isinstance(item, GrPoly): expression += item.to_sexpr(indent+2, pts_newline=True) else: From fef502102f794469030ac7f99236b5304ab23dcc Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:06:05 +0100 Subject: [PATCH 7/8] Footprint: Added image token --- src/kiutils/footprint.py | 91 ++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 51 deletions(-) diff --git a/src/kiutils/footprint.py b/src/kiutils/footprint.py index ff02122..08b55df 100644 --- a/src/kiutils/footprint.py +++ b/src/kiutils/footprint.py @@ -23,7 +23,7 @@ from os import path from kiutils.items.zones import Zone -from kiutils.items.common import Position, Coordinate, Net, Group, Font +from kiutils.items.common import Image, Position, Coordinate, Net, Group, Font from kiutils.items.fpitems import * from kiutils.items.gritems import * from kiutils.utils import sexpr @@ -776,10 +776,13 @@ def libId(self, symbol_id: str): attributes: Attributes = field(default_factory=lambda: Attributes()) """The optional ``attributes`` section defines the attributes of the footprint""" + # TODO: Type hinting for this list graphicItems: List = field(default_factory=list) - """The ``graphic`` objects section is a list of one or more graphical objects in the footprint. At a - minimum, the reference designator and value text objects are defined. All other graphical objects - are optional.""" + """The ``graphic`` objects section is a list of one or more graphical objects in the footprint. + Possible items are defined in ``kiutils.items.fpitems``. At minimum the reference designator + and value text objects are defined. All other graphical objects are optional. + + The ``Image`` token is supported since KiCad v7 and must be added into this list when used.""" pads: List[Pad] = field(default_factory=list) """The optional ``pads`` section is a list of pads in the footprint""" @@ -825,55 +828,41 @@ def from_sexpr(cls, exp: list) -> Footprint: if item == 'placed': object.placed = True continue - if (item[0] == 'version'): object.version = item[1] - if (item[0] == 'generator'): object.generator = item[1] - if (item[0] == 'layer'): object.layer = item[1] - if (item[0] == 'tedit'): object.tedit = item[1] - if (item[0] == 'tstamp'): object.tstamp = item[1] - if (item[0] == 'descr'): object.description = item[1] - if (item[0] == 'tags'): object.tags = item[1] - if (item[0] == 'path'): object.path = item[1] - if (item[0] == 'at'): object.position = Position().from_sexpr(item) - if (item[0] == 'autoplace_cost90'): object.autoplaceCost90 = item[1] - if (item[0] == 'autoplace_cost180'): object.autoplaceCost180 = item[1] - if (item[0] == 'solder_mask_margin'): object.solderMaskMargin = item[1] - if (item[0] == 'solder_paste_margin'): object.solderPasteMargin = item[1] - if (item[0] == 'solder_paste_ratio'): object.solderPasteRatio = item[1] - if (item[0] == 'clearance'): object.clearance = item[1] - if (item[0] == 'zone_connect'): object.zoneConnect = item[1] - if (item[0] == 'thermal_width'): object.thermalWidth = item[1] - if (item[0] == 'thermal_gap'): object.thermalGap = item[1] - - if item[0] == 'attr': - object.attributes = Attributes.from_sexpr(item) - if item[0] == 'model': - object.models.append(Model.from_sexpr(item)) - if item[0] == 'fp_text': - object.graphicItems.append(FpText.from_sexpr(item)) - if item[0] == 'fp_text_box': - object.graphicItems.append(FpTextBox.from_sexpr(item)) - if item[0] == 'fp_line': - object.graphicItems.append(FpLine.from_sexpr(item)) - if item[0] == 'fp_rect': - object.graphicItems.append(FpRect.from_sexpr(item)) - if item[0] == 'fp_circle': - object.graphicItems.append(FpCircle.from_sexpr(item)) - if item[0] == 'fp_arc': - object.graphicItems.append(FpArc.from_sexpr(item)) - if item[0] == 'fp_poly': - object.graphicItems.append(FpPoly.from_sexpr(item)) - if item[0] == 'fp_curve': - object.graphicItems.append(FpCurve.from_sexpr(item)) + if item[0] == 'version': object.version = item[1] + if item[0] == 'generator': object.generator = item[1] + if item[0] == 'layer': object.layer = item[1] + if item[0] == 'tedit': object.tedit = item[1] + if item[0] == 'tstamp': object.tstamp = item[1] + if item[0] == 'descr': object.description = item[1] + if item[0] == 'tags': object.tags = item[1] + if item[0] == 'path': object.path = item[1] + if item[0] == 'at': object.position = Position().from_sexpr(item) + if item[0] == 'autoplace_cost90': object.autoplaceCost90 = item[1] + if item[0] == 'autoplace_cost180': object.autoplaceCost180 = item[1] + if item[0] == 'solder_mask_margin': object.solderMaskMargin = item[1] + if item[0] == 'solder_paste_margin': object.solderPasteMargin = item[1] + if item[0] == 'solder_paste_ratio': object.solderPasteRatio = item[1] + if item[0] == 'clearance': object.clearance = item[1] + if item[0] == 'zone_connect': object.zoneConnect = item[1] + if item[0] == 'thermal_width': object.thermalWidth = item[1] + if item[0] == 'thermal_gap': object.thermalGap = item[1] + if item[0] == 'attr': object.attributes = Attributes.from_sexpr(item) + if item[0] == 'model': object.models.append(Model.from_sexpr(item)) + if item[0] == 'fp_text': object.graphicItems.append(FpText.from_sexpr(item)) + if item[0] == 'fp_text_box': object.graphicItems.append(FpTextBox.from_sexpr(item)) + if item[0] == 'fp_line': object.graphicItems.append(FpLine.from_sexpr(item)) + if item[0] == 'fp_rect': object.graphicItems.append(FpRect.from_sexpr(item)) + if item[0] == 'fp_circle': object.graphicItems.append(FpCircle.from_sexpr(item)) + if item[0] == 'fp_arc': object.graphicItems.append(FpArc.from_sexpr(item)) + if item[0] == 'fp_poly': object.graphicItems.append(FpPoly.from_sexpr(item)) + if item[0] == 'fp_curve': object.graphicItems.append(FpCurve.from_sexpr(item)) + if item[0] == 'image':object.graphicItems.append(Image.from_sexpr(item)) + if item[0] == 'pad': object.pads.append(Pad.from_sexpr(item)) + if item[0] == 'zone': object.zones.append(Zone.from_sexpr(item)) + if item[0] == 'property': object.properties.update({ item[1]: item[2] }) + if item[0] == 'group': object.groups.append(Group.from_sexpr(item)) if item[0] == 'dimension': raise NotImplementedError("Dimensions are not yet handled! Please report this bug along with the file being parsed.") - if item[0] == 'pad': - object.pads.append(Pad.from_sexpr(item)) - if item[0] == 'zone': - object.zones.append(Zone.from_sexpr(item)) - if item[0] == 'property': - object.properties.update({ item[1]: item[2] }) - if item[0] == 'group': - object.groups.append(Group.from_sexpr(item)) return object From 151a620ccee52dce631e1c5bc90927eff517959e Mon Sep 17 00:00:00 2001 From: Marvin Mager <99667992+mvnmgrx@users.noreply.github.com> Date: Thu, 9 Mar 2023 22:06:31 +0100 Subject: [PATCH 8/8] Test: Relaxed board/since_v7/test_imageWithLayerToken --- tests/testdata/board/since_v7/test_imageWithLayerToken | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testdata/board/since_v7/test_imageWithLayerToken b/tests/testdata/board/since_v7/test_imageWithLayerToken index f049297..05fa6f9 100644 --- a/tests/testdata/board/since_v7/test_imageWithLayerToken +++ b/tests/testdata/board/since_v7/test_imageWithLayerToken @@ -6,7 +6,6 @@ (paper "A4") (layers - (0 "F.Cu" signal) ) (setup @@ -25,4 +24,5 @@ p+sXX34XbntMjMqhmdFHjaaf0QRKPkrA0AyQUaPRAACmk1AZ+UHU4QAAAABJRU5ErkJggg== ) ) + )