buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

Buildozer: Add "key: value" to dict

Open MarkusTeufelberger opened this issue 8 years ago • 10 comments

I couldn't find any way to add a key/value pair to a dictionary attribute. Am I missing something or is this functionality simply not there?

MarkusTeufelberger avatar Aug 14 '17 13:08 MarkusTeufelberger

It looks like there is a function DictionarySet in edit.go but no commandline trigger to use that in edit/buildozer.go

Feel free to add and send a PR

pmbethe09 avatar Aug 15 '17 14:08 pmbethe09

Which keyword would you prefer?

Maybe something like "dict_add"/"dict_replace"/"dict_move" similar to the list functionality?

MarkusTeufelberger avatar Aug 15 '17 14:08 MarkusTeufelberger

@laurentlb -- thoughts?

pmbethe09 avatar Aug 15 '17 15:08 pmbethe09

This can be useful, indeed. Can describe more precisely the syntax you suggest?

laurentlb avatar Aug 24 '17 14:08 laurentlb

The current functionality of add:

add <attr> <value(s)>: Adds value(s) to a list attribute of a rule. If a value is already present in the list, it is not added.

How I would expect dict_add to work:

dict_add <attr> <key> <value>: Adds a value at a certain key to a dict attribute of a rule. If a value is already present at this key in the dict, it is not added.

Currently I'm creating dict attributes by just using set and entering a dict in there, which works but isn't pretty. It also makes it awkward to edit dicts.

MarkusTeufelberger avatar Aug 24 '17 18:08 MarkusTeufelberger

Great, looks good!

laurentlb avatar Aug 24 '17 19:08 laurentlb

Any news on this?

PaulSonOfLars avatar Sep 14 '18 14:09 PaulSonOfLars

Not from my side.

MarkusTeufelberger avatar Sep 14 '18 16:09 MarkusTeufelberger

Great, I'll open a PR for this in a bit then! dict_add, dict_set, and dict_remove should cover all dict essentials?

PaulSonOfLars avatar Sep 17 '18 09:09 PaulSonOfLars

Shouldn't this issue be closed now? It was implemented by PR#421.

bpfoley avatar Jun 24 '21 08:06 bpfoley

@vladmos ☝🏻

alexeagle avatar Nov 09 '23 15:11 alexeagle

Fixed by #421

vladmos avatar Nov 09 '23 15:11 vladmos