Scripts and functions used by other modules

Project metadata/configuration

Metadata and configuration for the project are stored in the .kicad_helpers_config directory (including KiBot config files for producting manufacturing outputs via continuous integration). Additional metadata (e.g., project summary, website, and manufacturing details) is stored in the project's kitspace.yaml file which makes it easy for other people to manufacture boards using https://kitspace.org/.

get_git_root[source]

get_git_root(path='.')

setup_test_repo[source]

setup_test_repo(root:"project root directory"='_temp')

Setup a test KiCad repository to test against.

get_project_name[source]

get_project_name(root='.')

Get the project name based on the name of the KiCad *.pro file.

> get_project_name()
40-channel-hv-switching-board

get_project_metadata[source]

get_project_metadata(root='.')

Get the project metatdata from the kitspace.yaml file.

> get_project_metadata()
{'color': 'black',
 'project_name': '40-channel-hv-switching-board',
 'site': 'https://github.com/sci-bots/dropbot-40-channel-HV-switching-board.kicad',
 'summary': 'DropBot v3 40-channel high-voltage switching board'}

get_schematic_path[source]

get_schematic_path(root='.')

Get the path to the KiCad schematic.

> get_schematic_path()
/home/ryan/dev/python/kicad-helpers/_temp/40-channel-hv-switching-board.sch

get_bom_path[source]

get_bom_path(root='.')

Get the path to the BOM.

> get_bom_path()
/home/ryan/dev/python/kicad-helpers/_temp/manufacturing/default/40-channel-hv-switching-board-BOM.csv

get_board_path[source]

get_board_path(root='.')

Get the path to the KiCad board file.

> get_board_path()
/home/ryan/dev/python/kicad-helpers/_temp/40-channel-hv-switching-board.kicad_pcb

get_manufacturers[source]

get_manufacturers(root='.')

Get the supported manufacturers.

> get_manufacturers()
['default', 'PCBWay']

get_gitignore_list[source]

get_gitignore_list(root='.')

> get_gitignore_list()
['_autosave*', '*bak', '*.xml', '.ipynb_checkpoints', '*-erc.txt', '*-drc.txt', 'kibot_errors.filter']
get_gitignore_list(root)
['_autosave*',
 '*bak',
 '*.xml',
 '.ipynb_checkpoints',
 '*-erc.txt',
 '*-drc.txt',
 'kibot_errors.filter']

in_gitignore[source]

in_gitignore(filename, root='.')

run_docker_cmd[source]

run_docker_cmd(cmd, workdir, container, v=False)

Run a command in a docker container under a UID mapped to the current user. This ensures that the current user is owner of any files created in the workdir.

run_kibot_docker[source]

run_kibot_docker(config:"KiBot configuation file", root:"project root directory"='.', v:"verbose"=False, output:"output path relative to ROOT"='.')

Run KiBot in a local docker container.

get_board_metadata[source]

get_board_metadata(root='.')

Get metadata from the *.kicad_pcb board file.

get_board_metadata(root)
{'title': '"40-channel HV switching board"',
 'date': '2021-11-24',
 'rev': 'v1.0',
 'company': '"Sci-Bots Inc."'}

update_board_metadata[source]

update_board_metadata(update_dict, root='.')

Update metadata in the *.kicad_pcb board file.

get_board_metadata(root)
{'title': '"40-channel HV switching board"',
 'date': '2021-11-24',
 'rev': 'v1.0',
 'company': '"Sci-Bots Inc."'}
original_metadata = get_board_metadata(root)

# Test setting new metadata
new_metadata = {"title": '"new title"',
    "date": '"new date"',
    "rev": '"new rev"',
    "company": '"new company"'
}
update_board_metadata(new_metadata, root)
assert get_board_metadata(root) == new_metadata

# Restore original metadata
update_board_metadata(original_metadata, root)
assert get_board_metadata(root) == original_metadata

get_schematic_metadata[source]

get_schematic_metadata(root, filename=None)

Get metadata from a *.sch schematic file.

get_schematic_metadata(root)
{'Title': '"40-channel HV switching board"',
 'Date': '"2021-11-24"',
 'Rev': '"v1.0"',
 'Comp': '"Sci-Bots Inc."'}
get_schematic_metadata(root, filename="switches_0-19.sch")
{'Title': '"40-channel HV switching board"',
 'Date': '"2021-11-24"',
 'Rev': '"v1.0"',
 'Comp': '"Sci-Bots Inc."'}

update_schematic_metadata[source]

update_schematic_metadata(update_dict:dict, root:str='.', all_sheets:bool=True)

Update metadata in a *.sch schematic file.

original_metadata = get_schematic_metadata(root)
original_metadata
{'Title': '"40-channel HV switching board"',
 'Date': '"2021-11-24"',
 'Rev': '"v1.0"',
 'Comp': '"Sci-Bots Inc."'}
new_metadata = {"Title": '"new title"',
    "Date": '"new date"',
    "Rev": '"new rev"',
    "Comp": '"new company"'
}
update_schematic_metadata(new_metadata, root, all_sheets=True)
assert get_schematic_metadata(root) == new_metadata
assert get_schematic_metadata(root, "switches_0-19.sch") == new_metadata

# Restore original metadata
update_schematic_metadata(original_metadata, root, all_sheets=True)
assert get_schematic_metadata(root) == original_metadata
assert get_schematic_metadata(root, "switches_0-19.sch") == original_metadata

github_badge[source]

github_badge(root='.')

kitspace_badge[source]

kitspace_badge(root='.')