Portindex2json: Make the license field consistent with "port info" command#6
Conversation
5698b25 to
9e0f449
Compare
|
I don't think I agree. Just as the data is in machine-readable format in the PortIndex and is formatted to be human readable in |
|
A TCL list in portindex.json is only as good as a string. We can either make it a list of strings in JSON also or leave it as it is and do everything while rendering in the webapp. Changing things in portindex.json will anyway require some work on the database also. So, we can close this and move ahead with macports/macports-webapp#235 which formats the license field when rendering the pages (unless there are any other suggestions). |
PortIndex is a Tcl file, so of course it contains Tcl data structures. PortIndex.json is supposed to be a JSON file, so I assumed it would have JSON representations of the data. I see now that for the license field it just contains the Tcl string. That seems wrong to me. Taking the example of the py-setuptools port, its license in Tcl representation is |
I tend to agree, that would be a better approach. Among other things, it avoids limiting what else can be done with the JSON. |
9e0f449 to
2585809
Compare
Thank you, I have done the changes and new license field now looks like this in JSON: This should be the correct representation in JSON. I am converting this PR to draft as it should not be merged before the needed changes get deployed on the webapp. I have used recursion to minimize the lines of code, not sure if is a good idea- that code block could use some feedback. |
ryandesign
left a comment
There was a problem hiding this comment.
Thanks! It looks good to me. I don't know whether the recursion could be a problem. Not sure how Tcl handles recursion. But assuming it handles it at all, which it seems to, the license field won't be that complex that it would cause very much recursion.
| array unset json_portinfo | ||
| foreach key [array names portinfo] { | ||
| if {$key eq "categories" || $key eq "variants" || [string match "depends_*" $key]} { | ||
| if {$key eq "categories" || $key eq "variants" || $key eq "license" || [string match "depends_*" $key]} { |
There was a problem hiding this comment.
By the way you can use the in operator here, as in:
if {$key in [list categories variants license] || [string match "depends_*" $key]} {
2585809 to
1dda9ba
Compare
1dda9ba to
346d7c8
Compare
|
This can now be merged unless there is any feedback. |
|
So just to make it clear, here's how we would want the Tcl transformed (
|
|
Yes (except "(Apache-2 or BSD)"). |
Oh, sorry, yes (question fixed). |
Closes: macports/macports-webapp#44