Skip to content

Commit 6e4624d

Browse files
author
devbisme
committed
feat: Refactor default pin settings to use constants for improved maintainability
1 parent 7586235 commit 6e4624d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

kipart/kipart.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
except ImportError:
6666
__version__ = "unknown"
6767

68+
# Constants for pin default settings
69+
DEFAULT_SIDE = "left" # Default pin side for unspecified pins
70+
DEFAULT_STYLE = "line" # Default pin style for unspecified pins
71+
DEFAULT_TYPE = "passive" # Default pin type for unspecified pins
72+
6873
# Constants for layout calculations
6974
FONT_SIZE = 1.27 # Default font size for pin names and numbers
7075
GRID_SPACING = 1.27 # Grid spacing for aligning pins and symbols
@@ -83,6 +88,7 @@
8388
TB_SEPARATION = (
8489
2 * GRID_SPACING
8590
) # Minimum separation between opposing pin names on top and bottom sides
91+
DEFAULT_PUSH = 0.5 # Default push value for pin alignment (centered)
8692

8793
# Enable/disable debugging diagnostics
8894
debug = False
@@ -798,11 +804,11 @@ def rows_to_symbol(
798804
symbol_rows,
799805
sort_by="row",
800806
reverse=False,
801-
default_side="left",
802-
default_type="passive",
803-
default_style="line",
807+
default_side=DEFAULT_SIDE,
808+
default_type=DEFAULT_TYPE,
809+
default_style=DEFAULT_STYLE,
804810
alt_pin_delim=None,
805-
push=0.5,
811+
push=DEFAULT_PUSH,
806812
bundle=False,
807813
scrunch=False,
808814
ccw=False,
@@ -1282,14 +1288,14 @@ def rows_to_symbol_lib(
12821288
rows,
12831289
sort_by="row",
12841290
reverse=False,
1285-
default_side="left",
1286-
default_type="passive",
1287-
default_style="line",
1291+
default_side=DEFAULT_SIDE,
1292+
default_type=DEFAULT_TYPE,
1293+
default_style=DEFAULT_STYLE,
12881294
alt_pin_delim=None,
12891295
bundle=False,
12901296
scrunch=False,
12911297
ccw=False,
1292-
push=0.5,
1298+
push=DEFAULT_PUSH,
12931299
):
12941300
"""
12951301
Generate a complete KiCad symbol library from CSV or Excel data.
@@ -1379,15 +1385,15 @@ def row_file_to_symbol_lib_file(
13791385
symbol_lib_file=None,
13801386
sort_by="row",
13811387
reverse=False,
1382-
default_side="left",
1383-
default_type="passive",
1384-
default_style="line",
1388+
default_side=DEFAULT_SIDE,
1389+
default_type=DEFAULT_TYPE,
1390+
default_style=DEFAULT_STYLE,
13851391
alt_pin_delim=None,
13861392
overwrite=False,
13871393
bundle=False,
13881394
scrunch=False,
13891395
ccw=False,
1390-
push=0.5,
1396+
push=DEFAULT_PUSH,
13911397
):
13921398
"""
13931399
Convert a CSV or Excel file to a KiCad symbol library file.
@@ -1644,12 +1650,12 @@ def kipart():
16441650
)
16451651
parser.add_argument(
16461652
"--type",
1647-
default="passive",
1653+
default=DEFAULT_TYPE,
16481654
help="Default type for pins without a type specifier (e.g., input, output, bidirectional, passive)",
16491655
)
16501656
parser.add_argument(
16511657
"--style",
1652-
default="line",
1658+
default=DEFAULT_STYLE,
16531659
help="Default style for pins without a style specifier (e.g., line, inverted, clock)",
16541660
)
16551661
parser.add_argument(

0 commit comments

Comments
 (0)