kicad-python 0.1.0a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. kicad_python-0.1.0a0.dist-info/LICENSE +674 -0
  2. kicad_python-0.1.0a0.dist-info/METADATA +58 -0
  3. kicad_python-0.1.0a0.dist-info/RECORD +46 -0
  4. kicad_python-0.1.0a0.dist-info/WHEEL +4 -0
  5. kipy/__init__.py +20 -0
  6. kipy/board.py +242 -0
  7. kipy/board_types.py +377 -0
  8. kipy/client.py +66 -0
  9. kipy/common_types.py +40 -0
  10. kipy/enums/__init__.py +22 -0
  11. kipy/enums/_enums.py +206 -0
  12. kipy/geometry.py +94 -0
  13. kipy/kicad.py +92 -0
  14. kipy/project.py +50 -0
  15. kipy/project_types.py +28 -0
  16. kipy/proto/__init__.py +20 -0
  17. kipy/proto/board/__init__.py +20 -0
  18. kipy/proto/board/board_commands_pb2.py +37 -0
  19. kipy/proto/board/board_commands_pb2.pyi +310 -0
  20. kipy/proto/board/board_pb2.py +41 -0
  21. kipy/proto/board/board_pb2.pyi +296 -0
  22. kipy/proto/board/board_types_pb2.py +82 -0
  23. kipy/proto/board/board_types_pb2.pyi +1034 -0
  24. kipy/proto/common/__init__.py +23 -0
  25. kipy/proto/common/commands/__init__.py +21 -0
  26. kipy/proto/common/commands/base_commands_pb2.py +17 -0
  27. kipy/proto/common/commands/base_commands_pb2.pyi +58 -0
  28. kipy/proto/common/commands/editor_commands_pb2.py +68 -0
  29. kipy/proto/common/commands/editor_commands_pb2.pyi +623 -0
  30. kipy/proto/common/commands/project_commands_pb2.py +18 -0
  31. kipy/proto/common/commands/project_commands_pb2.pyi +57 -0
  32. kipy/proto/common/envelope_pb2.py +25 -0
  33. kipy/proto/common/envelope_pb2.pyi +180 -0
  34. kipy/proto/common/types/__init__.py +20 -0
  35. kipy/proto/common/types/base_types_pb2.py +83 -0
  36. kipy/proto/common/types/base_types_pb2.pyi +860 -0
  37. kipy/proto/common/types/project_settings_pb2.py +15 -0
  38. kipy/proto/common/types/project_settings_pb2.pyi +30 -0
  39. kipy/proto/schematic/schematic_commands_pb2.py +13 -0
  40. kipy/proto/schematic/schematic_commands_pb2.pyi +23 -0
  41. kipy/proto/schematic/schematic_types_pb2.py +25 -0
  42. kipy/proto/schematic/schematic_types_pb2.pyi +203 -0
  43. kipy/util/__init__.py +21 -0
  44. kipy/util/proto.py +61 -0
  45. kipy/util/units.py +31 -0
  46. kipy/wrapper.py +23 -0
@@ -0,0 +1,15 @@
1
+ """Generated protocol buffer code."""
2
+ from google.protobuf import descriptor as _descriptor
3
+ from google.protobuf import descriptor_pool as _descriptor_pool
4
+ from google.protobuf import symbol_database as _symbol_database
5
+ from google.protobuf.internal import builder as _builder
6
+ _sym_db = _symbol_database.Default()
7
+ from ...common.types import base_types_pb2 as common_dot_types_dot_base__types__pb2
8
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n#common/types/project_settings.proto\x12\x14kiapi.common.project\x1a\x1dcommon/types/base_types.proto"\x18\n\x08NetClass\x12\x0c\n\x04name\x18\x01 \x01(\tb\x06proto3')
9
+ _globals = globals()
10
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
11
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'common.types.project_settings_pb2', _globals)
12
+ if _descriptor._USE_C_DESCRIPTORS == False:
13
+ DESCRIPTOR._options = None
14
+ _globals['_NETCLASS']._serialized_start = 92
15
+ _globals['_NETCLASS']._serialized_end = 116
@@ -0,0 +1,30 @@
1
+ """
2
+ @generated by mypy-protobuf. Do not edit manually!
3
+ isort:skip_file
4
+
5
+ project_settings.proto
6
+ Messages that describes project settings shared between schematics and boards
7
+ """
8
+ import builtins
9
+ import google.protobuf.descriptor
10
+ import google.protobuf.message
11
+ import sys
12
+ if sys.version_info >= (3, 8):
13
+ import typing as typing_extensions
14
+ else:
15
+ import typing_extensions
16
+ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
17
+
18
+ @typing_extensions.final
19
+ class NetClass(google.protobuf.message.Message):
20
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
21
+ NAME_FIELD_NUMBER: builtins.int
22
+ name: builtins.str
23
+ 'The name of the netclass (the literal string "Default" for the default netclass)'
24
+
25
+ def __init__(self, *, name: builtins.str=...) -> None:
26
+ ...
27
+
28
+ def ClearField(self, field_name: typing_extensions.Literal['name', b'name']) -> None:
29
+ ...
30
+ global___NetClass = NetClass
@@ -0,0 +1,13 @@
1
+ """Generated protocol buffer code."""
2
+ from google.protobuf import descriptor as _descriptor
3
+ from google.protobuf import descriptor_pool as _descriptor_pool
4
+ from google.protobuf import symbol_database as _symbol_database
5
+ from google.protobuf.internal import builder as _builder
6
+ _sym_db = _symbol_database.Default()
7
+ from ..common.types import base_types_pb2 as common_dot_types_dot_base__types__pb2
8
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n"schematic/schematic_commands.proto\x12\x15kiapi.schematic.types\x1a\x1dcommon/types/base_types.protob\x06proto3')
9
+ _globals = globals()
10
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
11
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'schematic.schematic_commands_pb2', _globals)
12
+ if _descriptor._USE_C_DESCRIPTORS == False:
13
+ DESCRIPTOR._options = None
@@ -0,0 +1,23 @@
1
+ """
2
+ @generated by mypy-protobuf. Do not edit manually!
3
+ isort:skip_file
4
+
5
+ This program source code file is part of KiCad, a free EDA CAD application.
6
+
7
+ Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
8
+
9
+ This program is free software: you can redistribute it and/or modify it
10
+ under the terms of the GNU General Public License as published by the
11
+ Free Software Foundation, either version 3 of the License, or (at your
12
+ option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful, but
15
+ WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License along
20
+ with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ """
22
+ import google.protobuf.descriptor
23
+ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
@@ -0,0 +1,25 @@
1
+ """Generated protocol buffer code."""
2
+ from google.protobuf import descriptor as _descriptor
3
+ from google.protobuf import descriptor_pool as _descriptor_pool
4
+ from google.protobuf import symbol_database as _symbol_database
5
+ from google.protobuf.internal import builder as _builder
6
+ _sym_db = _symbol_database.Default()
7
+ from ..common.types import base_types_pb2 as common_dot_types_dot_base__types__pb2
8
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1fschematic/schematic_types.proto\x12\x15kiapi.schematic.types\x1a\x1dcommon/types/base_types.proto"\xac\x01\n\x04Line\x12$\n\x02id\x18\x01 \x01(\x0b2\x18.kiapi.common.types.KIID\x12*\n\x05start\x18\x02 \x01(\x0b2\x1b.kiapi.common.types.Vector2\x12(\n\x03end\x18\x03 \x01(\x0b2\x1b.kiapi.common.types.Vector2\x12(\n\x05layer\x18\x04 \x01(\x0b2\x19.kiapi.common.types.Layer".\n\x04Text\x12&\n\x04text\x18\x01 \x01(\x0b2\x18.kiapi.common.types.Text"\x8c\x01\n\nLocalLabel\x12$\n\x02id\x18\x01 \x01(\x0b2\x18.kiapi.common.types.KIID\x12-\n\x08position\x18\x02 \x01(\x0b2\x1b.kiapi.common.types.Vector2\x12)\n\x04text\x18\x03 \x01(\x0b2\x1b.kiapi.schematic.types.Text"\x8d\x01\n\x0bGlobalLabel\x12$\n\x02id\x18\x01 \x01(\x0b2\x18.kiapi.common.types.KIID\x12-\n\x08position\x18\x02 \x01(\x0b2\x1b.kiapi.common.types.Vector2\x12)\n\x04text\x18\x03 \x01(\x0b2\x1b.kiapi.schematic.types.Text"\x93\x01\n\x11HierarchicalLabel\x12$\n\x02id\x18\x01 \x01(\x0b2\x18.kiapi.common.types.KIID\x12-\n\x08position\x18\x02 \x01(\x0b2\x1b.kiapi.common.types.Vector2\x12)\n\x04text\x18\x03 \x01(\x0b2\x1b.kiapi.schematic.types.Text"\x90\x01\n\x0eDirectiveLabel\x12$\n\x02id\x18\x01 \x01(\x0b2\x18.kiapi.common.types.KIID\x12-\n\x08position\x18\x02 \x01(\x0b2\x1b.kiapi.common.types.Vector2\x12)\n\x04text\x18\x03 \x01(\x0b2\x1b.kiapi.schematic.types.Textb\x06proto3')
9
+ _globals = globals()
10
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
11
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'schematic.schematic_types_pb2', _globals)
12
+ if _descriptor._USE_C_DESCRIPTORS == False:
13
+ DESCRIPTOR._options = None
14
+ _globals['_LINE']._serialized_start = 90
15
+ _globals['_LINE']._serialized_end = 262
16
+ _globals['_TEXT']._serialized_start = 264
17
+ _globals['_TEXT']._serialized_end = 310
18
+ _globals['_LOCALLABEL']._serialized_start = 313
19
+ _globals['_LOCALLABEL']._serialized_end = 453
20
+ _globals['_GLOBALLABEL']._serialized_start = 456
21
+ _globals['_GLOBALLABEL']._serialized_end = 597
22
+ _globals['_HIERARCHICALLABEL']._serialized_start = 600
23
+ _globals['_HIERARCHICALLABEL']._serialized_end = 747
24
+ _globals['_DIRECTIVELABEL']._serialized_start = 750
25
+ _globals['_DIRECTIVELABEL']._serialized_end = 894
@@ -0,0 +1,203 @@
1
+ """
2
+ @generated by mypy-protobuf. Do not edit manually!
3
+ isort:skip_file
4
+
5
+ This program source code file is part of KiCad, a free EDA CAD application.
6
+
7
+ Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
8
+
9
+ This program is free software: you can redistribute it and/or modify it
10
+ under the terms of the GNU General Public License as published by the
11
+ Free Software Foundation, either version 3 of the License, or (at your
12
+ option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful, but
15
+ WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License along
20
+ with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ """
22
+ import builtins
23
+ from .. import common
24
+ import google.protobuf.descriptor
25
+ import google.protobuf.message
26
+ import sys
27
+ if sys.version_info >= (3, 8):
28
+ import typing as typing_extensions
29
+ else:
30
+ import typing_extensions
31
+ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
32
+
33
+ @typing_extensions.final
34
+ class Line(google.protobuf.message.Message):
35
+ """/ Represents a schematic line segment, which may be a wire, bus, or graphical line"""
36
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
37
+ ID_FIELD_NUMBER: builtins.int
38
+ START_FIELD_NUMBER: builtins.int
39
+ END_FIELD_NUMBER: builtins.int
40
+ LAYER_FIELD_NUMBER: builtins.int
41
+
42
+ @property
43
+ def id(self) -> common.types.base_types_pb2.KIID:
44
+ ...
45
+
46
+ @property
47
+ def start(self) -> common.types.base_types_pb2.Vector2:
48
+ ...
49
+
50
+ @property
51
+ def end(self) -> common.types.base_types_pb2.Vector2:
52
+ ...
53
+
54
+ @property
55
+ def layer(self) -> common.types.base_types_pb2.Layer:
56
+ """*
57
+ One of: LAYER_BUS, LAYER_WIRE, LAYER_NOTES
58
+ """
59
+
60
+ def __init__(self, *, id: common.types.base_types_pb2.KIID | None=..., start: common.types.base_types_pb2.Vector2 | None=..., end: common.types.base_types_pb2.Vector2 | None=..., layer: common.types.base_types_pb2.Layer | None=...) -> None:
61
+ ...
62
+
63
+ def HasField(self, field_name: typing_extensions.Literal['end', b'end', 'id', b'id', 'layer', b'layer', 'start', b'start']) -> builtins.bool:
64
+ ...
65
+
66
+ def ClearField(self, field_name: typing_extensions.Literal['end', b'end', 'id', b'id', 'layer', b'layer', 'start', b'start']) -> None:
67
+ ...
68
+ global___Line = Line
69
+
70
+ @typing_extensions.final
71
+ class Text(google.protobuf.message.Message):
72
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
73
+ TEXT_FIELD_NUMBER: builtins.int
74
+
75
+ @property
76
+ def text(self) -> common.types.base_types_pb2.Text:
77
+ ...
78
+
79
+ def __init__(self, *, text: common.types.base_types_pb2.Text | None=...) -> None:
80
+ ...
81
+
82
+ def HasField(self, field_name: typing_extensions.Literal['text', b'text']) -> builtins.bool:
83
+ ...
84
+
85
+ def ClearField(self, field_name: typing_extensions.Literal['text', b'text']) -> None:
86
+ ...
87
+ global___Text = Text
88
+
89
+ @typing_extensions.final
90
+ class LocalLabel(google.protobuf.message.Message):
91
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
92
+ ID_FIELD_NUMBER: builtins.int
93
+ POSITION_FIELD_NUMBER: builtins.int
94
+ TEXT_FIELD_NUMBER: builtins.int
95
+
96
+ @property
97
+ def id(self) -> common.types.base_types_pb2.KIID:
98
+ ...
99
+
100
+ @property
101
+ def position(self) -> common.types.base_types_pb2.Vector2:
102
+ ...
103
+
104
+ @property
105
+ def text(self) -> global___Text:
106
+ ...
107
+
108
+ def __init__(self, *, id: common.types.base_types_pb2.KIID | None=..., position: common.types.base_types_pb2.Vector2 | None=..., text: global___Text | None=...) -> None:
109
+ ...
110
+
111
+ def HasField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> builtins.bool:
112
+ ...
113
+
114
+ def ClearField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> None:
115
+ ...
116
+ global___LocalLabel = LocalLabel
117
+
118
+ @typing_extensions.final
119
+ class GlobalLabel(google.protobuf.message.Message):
120
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
121
+ ID_FIELD_NUMBER: builtins.int
122
+ POSITION_FIELD_NUMBER: builtins.int
123
+ TEXT_FIELD_NUMBER: builtins.int
124
+
125
+ @property
126
+ def id(self) -> common.types.base_types_pb2.KIID:
127
+ ...
128
+
129
+ @property
130
+ def position(self) -> common.types.base_types_pb2.Vector2:
131
+ ...
132
+
133
+ @property
134
+ def text(self) -> global___Text:
135
+ ...
136
+
137
+ def __init__(self, *, id: common.types.base_types_pb2.KIID | None=..., position: common.types.base_types_pb2.Vector2 | None=..., text: global___Text | None=...) -> None:
138
+ ...
139
+
140
+ def HasField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> builtins.bool:
141
+ ...
142
+
143
+ def ClearField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> None:
144
+ ...
145
+ global___GlobalLabel = GlobalLabel
146
+
147
+ @typing_extensions.final
148
+ class HierarchicalLabel(google.protobuf.message.Message):
149
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
150
+ ID_FIELD_NUMBER: builtins.int
151
+ POSITION_FIELD_NUMBER: builtins.int
152
+ TEXT_FIELD_NUMBER: builtins.int
153
+
154
+ @property
155
+ def id(self) -> common.types.base_types_pb2.KIID:
156
+ ...
157
+
158
+ @property
159
+ def position(self) -> common.types.base_types_pb2.Vector2:
160
+ ...
161
+
162
+ @property
163
+ def text(self) -> global___Text:
164
+ ...
165
+
166
+ def __init__(self, *, id: common.types.base_types_pb2.KIID | None=..., position: common.types.base_types_pb2.Vector2 | None=..., text: global___Text | None=...) -> None:
167
+ ...
168
+
169
+ def HasField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> builtins.bool:
170
+ ...
171
+
172
+ def ClearField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> None:
173
+ ...
174
+ global___HierarchicalLabel = HierarchicalLabel
175
+
176
+ @typing_extensions.final
177
+ class DirectiveLabel(google.protobuf.message.Message):
178
+ DESCRIPTOR: google.protobuf.descriptor.Descriptor
179
+ ID_FIELD_NUMBER: builtins.int
180
+ POSITION_FIELD_NUMBER: builtins.int
181
+ TEXT_FIELD_NUMBER: builtins.int
182
+
183
+ @property
184
+ def id(self) -> common.types.base_types_pb2.KIID:
185
+ ...
186
+
187
+ @property
188
+ def position(self) -> common.types.base_types_pb2.Vector2:
189
+ ...
190
+
191
+ @property
192
+ def text(self) -> global___Text:
193
+ ...
194
+
195
+ def __init__(self, *, id: common.types.base_types_pb2.KIID | None=..., position: common.types.base_types_pb2.Vector2 | None=..., text: global___Text | None=...) -> None:
196
+ ...
197
+
198
+ def HasField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> builtins.bool:
199
+ ...
200
+
201
+ def ClearField(self, field_name: typing_extensions.Literal['id', b'id', 'position', b'position', 'text', b'text']) -> None:
202
+ ...
203
+ global___DirectiveLabel = DirectiveLabel
kipy/util/__init__.py ADDED
@@ -0,0 +1,21 @@
1
+ # This program source code file is part of KiCad, a free EDA CAD application.
2
+ #
3
+ # Copyright (C) 2024 KiCad Developers
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along
16
+ # with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # flake8: noqa
19
+
20
+ from .units import from_mm, to_mm
21
+ from .proto import pack_any, unpack_any, make_item_type
kipy/util/proto.py ADDED
@@ -0,0 +1,61 @@
1
+ # This program source code file is part of KiCad, a free EDA CAD application.
2
+ #
3
+ # Copyright (C) 2024 KiCad Developers
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along
16
+ # with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from google.protobuf.any_pb2 import Any
19
+ from google.protobuf.message import Message
20
+
21
+ from kipy.enums import KICAD_T
22
+ from kipy.proto.common.types import ItemType
23
+ from kipy.proto.board import board_types_pb2
24
+
25
+ def pack_any(object: Message) -> Any:
26
+ a = Any()
27
+ a.Pack(object)
28
+ return a
29
+
30
+ _any_urls = {
31
+ "type.googleapis.com/kiapi.board.types.Track": board_types_pb2.Track,
32
+ "type.googleapis.com/kiapi.board.types.Arc": board_types_pb2.Arc,
33
+ "type.googleapis.com/kiapi.board.types.Via": board_types_pb2.Via,
34
+ "type.googleapis.com/kiapi.board.types.Text": board_types_pb2.Text,
35
+ #"type.googleapis.com/kiapi.board.types.TextBox": board_types_pb2.TextBox,
36
+ "type.googleapis.com/kiapi.board.types.GraphicShape": board_types_pb2.GraphicShape,
37
+ "type.googleapis.com/kiapi.board.types.Pad": board_types_pb2.Pad,
38
+ "type.googleapis.com/kiapi.board.types.Zone": board_types_pb2.Zone,
39
+ "type.googleapis.com/kiapi.board.types.Dimension": board_types_pb2.Dimension,
40
+ "type.googleapis.com/kiapi.board.types.ReferenceImage": board_types_pb2.ReferenceImage,
41
+ "type.googleapis.com/kiapi.board.types.Group": board_types_pb2.Group,
42
+ "type.googleapis.com/kiapi.board.types.Field": board_types_pb2.Field,
43
+ "type.googleapis.com/kiapi.board.types.FootprintInstance": board_types_pb2.FootprintInstance
44
+ }
45
+
46
+ def unpack_any(object: Any) -> Message:
47
+ if len(object.type_url) == 0:
48
+ raise ValueError("Can't unpack empty Any protobuf message")
49
+
50
+ type = _any_urls.get(object.type_url, None)
51
+ if type is None:
52
+ raise NotImplementedError(f"{object.type_url} can't be unpacked")
53
+
54
+ concrete = type()
55
+ object.Unpack(concrete)
56
+ return concrete
57
+
58
+ def make_item_type(type: KICAD_T) -> ItemType:
59
+ t = ItemType()
60
+ t.type = type.value
61
+ return t
kipy/util/units.py ADDED
@@ -0,0 +1,31 @@
1
+ # This program source code file is part of KiCad, a free EDA CAD application.
2
+ #
3
+ # Copyright (C) 2024 KiCad Developers
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along
16
+ # with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ def from_mm(value_mm: float) -> int:
19
+ """
20
+ KiCad uses several internal unit systems, but for the IPC API, all distance units are defined as
21
+ 64-bit nanometers
22
+ :param value_mm: a quantity in millimeters
23
+ :return: the quantity in KiCad API units
24
+ """
25
+ return int(value_mm * 1_000_000)
26
+
27
+ def to_mm(value_nm: int) -> float:
28
+ """
29
+ Converts a KiCad API length/distance value (in nanometers) to millimeters
30
+ """
31
+ return float(value_nm) / 1_000_000
kipy/wrapper.py ADDED
@@ -0,0 +1,23 @@
1
+ # This program source code file is part of KiCad, a free EDA CAD application.
2
+ #
3
+ # Copyright (C) 2024 KiCad Developers
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU General Public License as published by the
7
+ # Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along
16
+ # with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from abc import ABC
19
+
20
+ class Wrapper(ABC):
21
+ @property
22
+ def proto(self):
23
+ return self.__dict__['_proto']