-
Notifications
You must be signed in to change notification settings - Fork 28
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
Added support for updating children units symbol ID #41
Conversation
Thanks for your contribution! I haven't had the time to fully go through your code, but here are some initial thoughts: At the moment i am uncertain if dealing with a subsymbol's unit or demorgan-ID is the responsibility Parsing the
These are all test cases that need to be considered. Parsing of the If this should be implemented, i would rather see two new attributes for the
Both fields The application implementing This should be more consistent to the KiCad documentation. Would such an approach fit your use-case? Happy to hear your thoughts on this. |
Hello @mvnmgrx Thanks for taking the time to review this PR!
I would counter argue that providing a mean to go from s-expr to python dataset means that the python dataset can be modified then exported back to s-expr. If
I was not aware of CI errors until now because I need your approval for running it 😉
Piggybacking on "KiCad Library Utils"
Also added, I agree it's better to stick to official doc, in this case I thought it would be more efficient to do it the way I did but meh no real reason to do so. |
Hello, thanks for incorporating this change. I marked some minor things in the code and i would be happy to merge your PR once fixed.
No problem ;-) You can also run the unit tests on your machine using One other thing to discuss: You have decided to pass a subsymbol's parent name via the
This would remove the
Looking forward to hear your thoughts on this and if such an approach would be okay for your use-case as well. PS: We also need unit tests for your implementation, but i can do that as well when your PR is merged Best regards |
The rabbit hole goes deeper... The unittests are failing because because the regex does not work .. Furthermore i noticed that a top level symbol may have a Traceback of one test that is failing:
When i change this .. symbol_id_parse = re.match(r"^" + re.escape(object.id) + r"_(\d+?)_(\d+?)$", symbol_unit.id) .. to this .. symbol_id_parse = re.search(r"_(\d+?)_(\d+?)$", symbol_unit.id) .. the tests ran but the output is not correct now. Comparing parts of this tests input:
to its output:
Subsymbols now also have this How about |
Hello @mvnmgrx Thanks for your thorough feedback, unfortunately I'm currently in vacation for the next couple of weeks... But I will definitely work on this when I come back, sorry for the delay! |
Hello @mvnmgrx Ok so in addition to your earlier review, here are the latest changes:
I ran my tests and yours and everything works fine on my side. Let me know what you think, thanks! |
Thanks for incorporating the changes! Hope you had a nice vacation as well. I've added some review notes, but read this comment first: The problem is that So it would be nicer to remove the Something like this: @property
def id(self):
unit_style_ids = f"_{self.unitId}_{self.styleId}" if (self.unitId and self.styleId) else ""
if self.libraryNickname:
return f'{self.libraryNickname}:{self.entryName}{unit_style_ids}'
else:
return f'{self.entryName}{unit_style_ids}'
@id.setter
def id(self, symbol_id):
# Split library id into nickname, entry name, unit id and style id (if any)
# Update the value property for parent-level symbols (keep in mind that this is a side-effect of this setter and needs to be documented!)
# Update child unit's id/name/etc (this may also be a side-effect, but is neccessary to keep consistency) This simplifies a lot in This would also remove My goal is to keep the implementation of the Symbol() class the same, regardless if we are dealing with a parent symbol or with a child symbol. |
Btw. i noticed that the SchematicSymbol() class also uses such a combined identifier. This may also be subject to change some time later if needed. |
…rections based on feedback
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.
All changes were implemented, please have a look at the new id.setter
method and let me know what do you think.
I am not sure what do you mean by documenting that the Value
property and units ID being updated automatically when main symbol ID changes, this is a behavior straight from KiCad so it mirrors it.
Nice work, thanks! I annotated two minor things in the review. Also some more thoughts on the following:
This may be the way KiCad does it in the library editor by default. But in the following example it would be unexpected behavior:
The other way around (changing the library ID and the Value stays the same) would also be possible in the schematic editor (using the "Change Symbol" button in its properties). Furthermore, setting the From this i would propose that the |
But this should be it. Then we have a nice consistent API for reading and writing both the raw library ID as well as its components. Looking forward to merging your PR after those changes! I'm going to write some more unittests after the merge to cover every part of the renaming as well as the regex parsing a bit more in detail. Should be done with that in the next few days, so it will be available in v1.2.2 asap. |
@mvnmgrx I totally understand for the Please check one last time on your side, I added a couple of tests for merging two libraries together and renaming a symbol. I have done some RegEx tests on the side to verify the logic, it checks out from what I could see. Thanks for taking so much of your time following up and helping out, really appreciated! |
Thanks for taking your time to contribute as well! |
FYI: I've renamed the Another thing that i changed was to simplify the parsing in |
@mvnmgrx Sure thing I can test your changes. Are you at the point where you will cut the |
Pretty soon, I'm planning on today evening for now (european time). It will furthermore be named v1.3.0 instead as they were too many breaking changes to still call this a "minor" update. |
Awesome, thanks for the update 👍 |
Looks good on my side 👍 |
Tested with Ki-nTree and works fine, happy to hear what do you think @mvnmgrx