Initial commit
This commit is contained in:
27
kibot/scripts/bootstrap.sh
Normal file
27
kibot/scripts/bootstrap.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# ============================================================================
|
||||
# KiBot Template Bootstrapping Script
|
||||
# ============================================================================
|
||||
|
||||
# Create the Development Branch
|
||||
git checkout -b dev
|
||||
echo "Created Development Branch"
|
||||
|
||||
# Add the Asymworks KiCad Library
|
||||
git remote add -f asymworks-kicad-lib https://git.asymworks.com/asymworks/kicad-library
|
||||
git subtree add --prefix lib/asymworks asymworks-kicad-lib main --squash -m "[bootstrap] Add subtree 'Asymworks/KiCad-Library' at 'lib/asymworks'"
|
||||
echo "Added Asymworks KiCad Library"
|
||||
|
||||
# Rename the KiCad Project based on the directory name
|
||||
PROJ_NAME=$(basename "$PWD")
|
||||
git mv Asymworks_Template.kicad_pro "${PROJ_NAME}.kicad_pro"
|
||||
git mv Asymworks_Template.kicad_sch "${PROJ_NAME}.kicad_sch"
|
||||
git mv Asymworks_Template.kicad_pcb "${PROJ_NAME}.kicad_pcb"
|
||||
git commit -a -m 'Rename Project'
|
||||
echo "Renamed project to \"${PROJ_NAME}.kicad_pro\""
|
||||
|
||||
# Push the Develpment Branch to Gitea
|
||||
git push -u origin dev
|
||||
|
||||
# Bootstrap Complete
|
||||
echo "Bootstrap complete. Please run 'git pull' after the CI action finishes.'
|
||||
49
kibot/scripts/get_sheet_title.py
Normal file
49
kibot/scripts/get_sheet_title.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import argparse
|
||||
import xml.etree.ElementTree as ET
|
||||
import sys
|
||||
|
||||
def get_sheet_title(file_path, page_number, dots_number):
|
||||
try:
|
||||
tree = ET.parse(file_path)
|
||||
root = tree.getroot()
|
||||
|
||||
page_number = str(page_number)
|
||||
titles = []
|
||||
|
||||
for sheet in root.findall(".//sheet"):
|
||||
number = sheet.get("number")
|
||||
if number == page_number:
|
||||
# Get the last part of the 'name' attribute after '/'
|
||||
name = sheet.get("name")
|
||||
title_block = sheet.find("title_block")
|
||||
title = title_block.find("title").text if title_block is not None else None
|
||||
if name:
|
||||
titles.append(name.split("/")[-2 if name.endswith("/") else -1])
|
||||
|
||||
if not titles:
|
||||
print('.'*dots_number)
|
||||
|
||||
elif len(set(titles)) > 1:
|
||||
print("Conflicting page numbers")
|
||||
else:
|
||||
print(titles[0])
|
||||
except ET.ParseError:
|
||||
print("Error: Invalid XML format")
|
||||
except FileNotFoundError:
|
||||
print("Error: XML File not found")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Get the sheet title based on page number from a KiCad XML file")
|
||||
parser.add_argument("-p", "--page-number", type=int, required=True, help="Page number to search")
|
||||
parser.add_argument("-f", "--file", type=str, required=True, help="Path to the schematic XML file")
|
||||
parser.add_argument("-d", "--dots-number", type=int, required=True, help="Number of dots for empty lines")
|
||||
|
||||
args = parser.parse_args()
|
||||
get_sheet_title(args.file, args.page_number, args.dots_number)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user