Closed larpon closed 5 years ago
I'll leave the review up to Razvan as he's the one who's comfortable with functional programming here Thanks 🙂
Really appreciate your interest here @Larpon, I'm gonna give you some quick tips on how to tackle something like this and come up with a far simpler fix for this, might come in handy for other projects too :).
So if we check the error it says that: TypeError: 'map' object is not subscriptable
and that happens because of https://github.com/GDquest/GDquest-art-tools/blob/073bd51db85bbd12bbf9737547d9396500f5edb6/gdquest_art_tools/Infrastructure.py#L41.
All of these meta
keywords have by design at least one element in them even if they're not provided by the user so it isn't a problem of them being empty or "falsy" objects. So your checks aren't going to do what you think they're going to do. All you're doing really is converting the map
objects into list
objects and that's exactly what we need, but it can be done in a far simpler way.
Instead of having those additional checks that may or may not keep in sync with the rest of the code, we just need to replace that line: meta.update({k: map(int, v) for k, v in meta.items() if k in 'ms'})
with meta.update({k: list(map(int, v)) for k, v in meta.items() if k in 'ms'})
.
This way we're "correctly" using list
s for all of the meta keys instead of a mix of list
& map
objects.
I've thought a tiny bit about this portion of the code and how you return the path from save
, I'm not entirely sure I like this approach since save exports to many paths. We'll likely have to come up with something better for the COA exporter, especially when expanding it to spreadsheet type of things & applying multiple margin/scale etc. options.
Fully agreed - I was thinking about a separate save function as well. This was just a quick and dirty fix to make it usable again :)
We don't do dirty fixes here :)
This should make the plug-in work in all exports