Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Exporters: PCB: KiCad: git_version util (#52)
Browse files Browse the repository at this point in the history
Add: git_version util
  • Loading branch information
ruben-iteng authored Sep 11, 2024
1 parent 85c7498 commit 9096ef0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/faebryk/exporters/pcb/kicad/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import pprint
import re
import subprocess
from abc import abstractmethod
from dataclasses import fields
from enum import Enum, auto
Expand Down Expand Up @@ -1099,6 +1100,7 @@ def set_pcb_outline_complex(

# find bounding box

# Silkscreen -----------------------------------------------------------------------
class Side(Enum):
TOP = auto()
BOTTOM = auto()
Expand Down Expand Up @@ -1159,3 +1161,43 @@ def set_designator_position(
reference.at = C_xyr(
max_coord.x + offset + displacement.x, displacement.y, rot
)

def add_git_version(
self,
center_at: C_xyr,
layer: str = "F.SilkS",
font: Font = Font(size=C_wh(1, 1), thickness=0.2),
knockout: bool = True,
alignment: tuple[
C_effects.E_justify, C_effects.E_justify, C_effects.E_justify
] = (
C_effects.E_justify.center,
C_effects.E_justify.center,
C_effects.E_justify.normal,
),
):
# check if gitcli is available
try:
subprocess.check_output(["git", "--version"])
except subprocess.CalledProcessError:
logger.warning("git is not installed")
git_human_version = "git is not installed"

try:
git_human_version = (
subprocess.check_output(["git", "describe", "--always"])
.strip()
.decode("utf-8")
)
except subprocess.CalledProcessError:
logger.warning("Cannot get git project version")
git_human_version = "Cannot get git project version"

self.insert_text(
text=git_human_version,
at=center_at,
layer=layer,
font=font,
alignment=alignment,
knockout=knockout,
)

0 comments on commit 9096ef0

Please sign in to comment.