Closed ohare93 closed 1 year ago
Thanks so much for the fast implementation! It works! :)
Isn't a (slight) design issue that this prevents BrainBrew from being able to (even in principle) import changes to the deck name (and the crowdanki_uuid
)? (when running anki_to_source)
(BrainBrew currently doesn't allow writing to the YAML headers file, but in principle it's possible, while if the name and crowdanki_uuid are hard-coded in the recipes then it becomes impossible even in principle.)
(I'm probably heavily overthinking this, though — anki_to_source
is currently probably only rarely used, and changing the deck name (and especially the deck UUID) from the Anki side will be extremely rare.)
Edit: One tiny thing I noticed is that in the built JSONs, the crowdanki_uuid
key is now after the desc
key (while all the other keys are still sorted).
Thanks so much for the fast implementation! It works! :)
No worries, any time :grin:
Isn't a (slight) design issue that this prevents BrainBrew from being able to (even in principle) import changes to the deck name (and the
crowdanki_uuid
)? (when running anki_to_source)
Not sure I understand what you are saying. That there should be a way to programmatically write to a Header?
(BrainBrew currently doesn't allow writing to the YAML headers file, but in principle it's possible, while if the name and crowdanki_uuid are hard-coded in the recipes then it becomes impossible even in principle.)
Doesn't headers_from_crowd_anki
do this? That is what is used in the brain_brew init
function to setup a repo. Or am I misunderstanding? 😅
I think that I'm overthinking this (firstly, changing headers is a very rare use-case to begin with, and secondly changing the name and UUID makes little sense and/or will break other things) so please feel free to ignore the below! (I'm not quite sure why I decided to type all of this up, given that I realised half-way through that it makes no sense...)
tldr; everything is fine design-wise, ignore the above.
On a more constructive note, the partial overrides issue is now fixed (there's no crash when only some fields are overridden)!
(The sorting is still as it was: first all the non-overridden fields, then desc
and then crowdanki_uuid
. I think if we want crowdanki_uuid
to be before desc
(but after non-overridden fields), then we need to change the order of keys in HeadersOverride.override
. If we want all header fields to be sorted. then (I think) we need to use sorted(self.data.items)
in Headers.data_without_name
.)
On a more constructive note, the partial overrides issue is now fixed (there's no crash when only some fields are overridden)!
:tada:
(The sorting is still as it was: first all the non-overridden fields, then
desc
and thencrowdanki_uuid
. I think if we wantcrowdanki_uuid
to be beforedesc
(but after non-overridden fields), then we need to change the order of keys inHeadersOverride.override
. If we want all header fields to be sorted. then (I think) we need to usesorted(self.data.items)
inHeaders.data_without_name
.)
Aaaahhhhhh you meant the order in the resulting CrowdAnki file, yes I see. That should be fixable :smile:
AFAICT this works perfectly (as we'd require for #566) with all even minor issues (key sorting) dealt with!
@ohare93 could you please merge this? (Not urgently!)
(I haven't tested it any more, but from what I remember from https://github.com/anki-geo/ultimate-geography/pull/566 it worked exactly as needed.)
Huh I never merged this? Whoops! Done 😁 I'll release a new version shortly 👍
@omarkohl I see you referenced this PR. It is released now, apologies for the delay! 😅
Thanks!
Added the ability to override name and crowdanki_uuid for a Deck Header.
For https://github.com/anki-geo/ultimate-geography/pull/566