Skip to content

Commit

Permalink
Move CoordinateX,Y,I,J to separate modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Jan 29, 2025
1 parent b7c8c99 commit ac7561f
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 262 deletions.
12 changes: 6 additions & 6 deletions src/pygerber/builder/gerber.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from pydantic import BaseModel, Field

from pygerber.gerber.ast import CoordinateFormat
from pygerber.gerber.ast import CoordinateFormat, PlotMode
from pygerber.gerber.ast.nodes import (
ADC,
ADO,
Expand All @@ -32,6 +32,9 @@
D02,
D03,
FS,
G01,
G02,
G03,
G36,
G37,
G75,
Expand All @@ -54,6 +57,8 @@
Code20,
Code21,
Constant,
CoordinateI,
CoordinateJ,
CoordinateNotation,
CoordinateX,
CoordinateY,
Expand All @@ -69,11 +74,6 @@
UnitMode,
Zeros,
)
from pygerber.gerber.ast.nodes.g_codes.G01 import G01
from pygerber.gerber.ast.nodes.g_codes.G02 import G02
from pygerber.gerber.ast.nodes.g_codes.G03 import G03
from pygerber.gerber.ast.nodes.other.coordinate import CoordinateI, CoordinateJ
from pygerber.gerber.ast.state_tracking_visitor import PlotMode

if TYPE_CHECKING:
from typing_extensions import Self, TypeAlias
Expand Down
178 changes: 89 additions & 89 deletions src/pygerber/gerber/ast/nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
ImagePolarity,
Mirroring,
Mount,
Part,
Polarity,
UnitMode,
Zeros,
Expand Down Expand Up @@ -112,13 +113,11 @@
from pygerber.gerber.ast.nodes.math.parenthesis import Parenthesis
from pygerber.gerber.ast.nodes.math.point import Point
from pygerber.gerber.ast.nodes.math.variable import Variable
from pygerber.gerber.ast.nodes.other.coordinate import (
Coordinate,
CoordinateI,
CoordinateJ,
CoordinateX,
CoordinateY,
)
from pygerber.gerber.ast.nodes.other.coordinate import Coordinate
from pygerber.gerber.ast.nodes.other.CoordinateI import CoordinateI
from pygerber.gerber.ast.nodes.other.CoordinateJ import CoordinateJ
from pygerber.gerber.ast.nodes.other.CoordinateX import CoordinateX
from pygerber.gerber.ast.nodes.other.CoordinateY import CoordinateY
from pygerber.gerber.ast.nodes.primitives.code_0 import Code0
from pygerber.gerber.ast.nodes.primitives.code_1 import Code1
from pygerber.gerber.ast.nodes.primitives.code_2 import Code2
Expand Down Expand Up @@ -146,55 +145,18 @@
)

__all__ = [
"ABclose",
"ABopen",
"ADC",
"ADmacro",
"AB",
"AD",
"ADC",
"ADO",
"ADP",
"ADR",
"AMclose",
"AMopen",
"SR",
"SRclose",
"SRopen",
"TA_AperFunction",
"TA_DrillTolerance",
"TA_FlashText",
"TA_UserName",
"TD",
"TF_MD5",
"TF_CreationDate",
"TF_FileFunction",
"TF_FilePolarity",
"TF_GenerationSoftware",
"TF_Part",
"TF_ProjectId",
"TF_SameCoordinates",
"TF_UserName",
"TO_C",
"TO_CMNP",
"TO_N",
"TO_P",
"TO_CFtp",
"TO_CHgt",
"TO_CLbD",
"TO_CLbN",
"TO_CMfr",
"TO_CMnt",
"TO_CPgD",
"TO_CPgN",
"TO_CRot",
"TO_CSup",
"TO_CVal",
"TO_UserName",
"AM",
"AS",
"D01",
"D02",
"D03",
"Dnn",
"File",
"G",
"FS",
"G01",
"G02",
"G03",
Expand All @@ -209,6 +171,9 @@
"G75",
"G90",
"G91",
"IN",
"IP",
"IR",
"LM",
"LN",
"LP",
Expand All @@ -217,20 +182,30 @@
"M00",
"M01",
"M02",
"Assignment",
"Constant",
"MI",
"MO",
"OF",
"SF",
"SR",
"TA",
"TD",
"TF",
"TF_MD5",
"TO",
"TO_C",
"TO_CMNP",
"TO_N",
"TO_P",
"ABclose",
"ABopen",
"ADmacro",
"AMclose",
"AMopen",
"Add",
"Div",
"Mul",
"Sub",
"Neg",
"Pos",
"Point",
"Variable",
"CoordinateI",
"CoordinateJ",
"CoordinateX",
"CoordinateY",
"AperFunction",
"ApertureIdStr",
"Assignment",
"AxisCorrespondence",
"Code0",
"Code1",
"Code2",
Expand All @@ -241,38 +216,63 @@
"Code20",
"Code21",
"Code22",
"AS",
"FS",
"IN",
"IP",
"IR",
"MI",
"MO",
"OF",
"SF",
"Double",
"Integer",
"ApertureIdStr",
"PackedCoordinateStr",
"Node",
"TA",
"TO",
"TF",
"Constant",
"Coordinate",
"CoordinateI",
"CoordinateJ",
"CoordinateNotation",
"CoordinateX",
"CoordinateY",
"Div",
"Dnn",
"Double",
"Expression",
"Parenthesis",
"AB",
"AM",
"SourceInfo",
"File",
"FileFunction",
"G",
"ImagePolarity",
"Integer",
"Invalid",
"AperFunction",
"CoordinateNotation",
"Mirroring",
"Mount",
"Mul",
"Neg",
"Node",
"PackedCoordinateStr",
"Parenthesis",
"Part",
"Point",
"Polarity",
"Pos",
"SRclose",
"SRopen",
"SourceInfo",
"Sub",
"TA_AperFunction",
"TA_DrillTolerance",
"TA_FlashText",
"TA_UserName",
"TF_CreationDate",
"TF_FileFunction",
"TF_FilePolarity",
"TF_GenerationSoftware",
"TF_Part",
"TF_ProjectId",
"TF_SameCoordinates",
"TF_UserName",
"TO_CFtp",
"TO_CHgt",
"TO_CLbD",
"TO_CLbN",
"TO_CMfr",
"TO_CMnt",
"TO_CPgD",
"TO_CPgN",
"TO_CRot",
"TO_CSup",
"TO_CVal",
"TO_UserName",
"UnitMode",
"Variable",
"Zeros",
"FileFunction",
"Mount",
"AxisCorrespondence",
"ImagePolarity",
]
10 changes: 4 additions & 6 deletions src/pygerber/gerber/ast/nodes/d_codes/D01.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from pydantic import Field

from pygerber.gerber.ast.nodes.d_codes.D import D
from pygerber.gerber.ast.nodes.other.coordinate import (
CoordinateI,
CoordinateJ,
CoordinateX,
CoordinateY,
)
from pygerber.gerber.ast.nodes.other.CoordinateI import CoordinateI
from pygerber.gerber.ast.nodes.other.CoordinateJ import CoordinateJ
from pygerber.gerber.ast.nodes.other.CoordinateX import CoordinateX
from pygerber.gerber.ast.nodes.other.CoordinateY import CoordinateY

if TYPE_CHECKING:
from typing_extensions import Self
Expand Down
6 changes: 2 additions & 4 deletions src/pygerber/gerber/ast/nodes/d_codes/D02.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from pydantic import Field

from pygerber.gerber.ast.nodes.d_codes.D import D
from pygerber.gerber.ast.nodes.other.coordinate import (
CoordinateX,
CoordinateY,
)
from pygerber.gerber.ast.nodes.other.CoordinateX import CoordinateX
from pygerber.gerber.ast.nodes.other.CoordinateY import CoordinateY

if TYPE_CHECKING:
from typing_extensions import Self
Expand Down
6 changes: 2 additions & 4 deletions src/pygerber/gerber/ast/nodes/d_codes/D03.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from pydantic import Field

from pygerber.gerber.ast.nodes.d_codes.D import D
from pygerber.gerber.ast.nodes.other.coordinate import (
CoordinateX,
CoordinateY,
)
from pygerber.gerber.ast.nodes.other.CoordinateX import CoordinateX
from pygerber.gerber.ast.nodes.other.CoordinateY import CoordinateY

if TYPE_CHECKING:
from typing_extensions import Self
Expand Down
28 changes: 28 additions & 0 deletions src/pygerber/gerber/ast/nodes/other/CoordinateI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""`pygerber.nodes.other.CoordinateI` module contains definition of `CoordinateI`
class which represent Ixx...x packed coordinates.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Callable

from pygerber.gerber.ast.nodes.other.coordinate import Coordinate

if TYPE_CHECKING:
from typing_extensions import Self

from pygerber.gerber.ast.ast_visitor import AstVisitor


class CoordinateI(Coordinate):
"""Represents I Coordinate node."""

def visit(self, visitor: AstVisitor) -> CoordinateI:
"""Handle visitor call."""
return visitor.on_coordinate_i(self)

def get_visitor_callback_function(
self, visitor: AstVisitor
) -> Callable[[Self], CoordinateI]:
"""Get callback function for the node."""
return visitor.on_coordinate_i
28 changes: 28 additions & 0 deletions src/pygerber/gerber/ast/nodes/other/CoordinateJ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""`pygerber.nodes.other.CoordinateJ` module contains definition of `CoordinateJ`
class which represent Jxx...x packed coordinates.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Callable

from pygerber.gerber.ast.nodes.other.coordinate import Coordinate

if TYPE_CHECKING:
from typing_extensions import Self

from pygerber.gerber.ast.ast_visitor import AstVisitor


class CoordinateJ(Coordinate):
"""Represents J Coordinate node."""

def visit(self, visitor: AstVisitor) -> CoordinateJ:
"""Handle visitor call."""
return visitor.on_coordinate_j(self)

def get_visitor_callback_function(
self, visitor: AstVisitor
) -> Callable[[Self], CoordinateJ]:
"""Get callback function for the node."""
return visitor.on_coordinate_j
Loading

0 comments on commit ac7561f

Please sign in to comment.