-
Notifications
You must be signed in to change notification settings - Fork 246
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
Improved inheritance #645
Improved inheritance #645
Conversation
This is very clever! I have one concern though. Will this confuse other yaml readers? Just as an example, I would love to have a core file parser in JavaScript to embed in websites, but then I would need to implement the same override for that yaml parsing library, right? |
The replacement of Also, I think this PR will actually improve compatibility with other YAML readers considering that the merge operator has been depreciated in YAML 1.2 (ref). |
Ouch... you're right. I had no idea. Hmm... knowing this, I wonder if we should do this in two stages.
|
Sounds good! I can resolve the merge conflicts and squash On how to add an explicit syntax: In this patch, users can already use Though I don't really see a need to do this. Right now, if they use the old one ( |
Great. Let's start with this. After I wrote my last comment I remembered that I did a quick PoC on an |
5b68751
to
0df5cc7
Compare
Alright, I believe it's ready. Thanks for the help, @olofk! |
Actually, I just realized |
0df5cc7
to
10e5b47
Compare
improved inheritance centralized inheritance calls remove extra import fixed lint issues improved yaml_merge_2_fusesoc_merge() lint
10e5b47
to
636c166
Compare
Alright, NOW it should be good I added the following tests to make sure that only valid merge key operators are replaced with fusesoc/tests/capi2_cores/parser/inheritance.core Lines 55 to 59 in 636c166
I had to modify the regex in fusesoc/fusesoc/capi2/inheritance.py Lines 14 to 23 in 636c166
|
Fantastic! Looks perfect. Thanks for your contributions. Picked and pushed! |
Fixes #639 and fixes #624
In summary, inheritance is no longer implemented by PyYAML's merge key implementation. Instead, it is overridden by a custom FuseSoC implementation
Specifics
Added fusesoc/capi2/inheritance.py to centralize logic related to inheritance
utils.yaml_fread()
now callsutils.yaml_read()
to improve code reusabilityPossibly fixed small bug in
utils.yaml_read()
by changingdata.read()
todata
. (There is no test in the CI that checks for this case, so I am uncertain whether this change is good)utils.yaml_read()
now replaces all merge key operators (<<
) with an intermediate value ofInheritance.MERGE_OPERATOR
, then turns the YAML into a dictionary as usual, then runs the newInheritance.elaborate_inheritance()
function that matches the specifications in Issues with Merge Keys #639Gave
utils.merge_dict()
the flagconcat_list_appends_only
that, when set toTrue
, will only concatenate arrays that end in"_append"
. Usuallyutils.merge_dict()
will concatenate all arrays