-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor BOM generation to centralize logic #177
Conversation
As it turns out, System Capture BOM generation did not get the benefits of the changes in #157 as the functions for filtering and sorting rows were not called in the system capture BOM function. This was an entirely avoidable mistake as the logic for BOM generation for all formats is substantially the same. This commit moves the logic for BOM generation into the `generate_bom` function and makes the format specific functions aliases of the same. This should avoid similar mistakes in the future.
Coverage SummaryTotal Project Coverage
Coverage by File
Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
Diff Coverage Detailsallspice/utils/list_components.pyLines 289-297 289 return SupportedTool.ORCAD
290 elif source_file.lower().endswith(".sdax"):
291 return SupportedTool.SYSTEM_CAPTURE
292 else:
! 293 raise ValueError("""
294 The source file for generate_bom must be:
295
296 - A PrjPcb file for Altium projects; or
297 - A DSN file for OrCAD projects; or |
if remove_non_bom_components: | ||
project_tool = infer_project_tool(source_file) | ||
if project_tool == SupportedTool.ALTIUM: | ||
components = _remove_non_bom_components(components) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless the plan is to use the same function for the other file formats I think we should prefix this as altium specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, the shared logic in nice and keeping the functions per format makes it easy to document each case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any PR with a net negative lines of code is a 👍 by me
As it turns out, System Capture BOM generation did not get the benefits of the changes in #157 as the functions for filtering and sorting rows were not called in the system capture BOM function. This was an entirely avoidable mistake as the logic for BOM generation for all formats is substantially the same. This commit moves the logic for BOM generation into the
generate_bom
function and makes the format specific functions aliases of the same. This should avoid similar mistakes in the future.Closes ID-529.