sachinraja / simple-icons-py

python wrapper for simple-icons
https://pypi.org/project/simpleicons/
MIT License
18 stars 3 forks source link

Reading _data/simple_icons.json instead of putting icons in all.py #2

Closed fbernhart closed 3 years ago

fbernhart commented 3 years ago

Looking through your package I was wondering why all the icons data is stored inside the all.py file and at the same time the same information is available as .json, pulled from the original Simple Icons project.

Wouldn't it be easier to just read the _data/simple_icons.json file and then extract the needed information from there? This would as well avoid having the same data saved twice, which seems quite redundant in my opinion.

I'm looking forward to hear your opinion. :)

sachinraja commented 3 years ago

This is a great question! This is actually what the NPM package does too (reference to that build file). Either way, all the svgs must be read to generate the .py files. I'm assuming the NPM package does this, so it does not rely on the filesystem for loading svgs from files. Since this isn't really applicable in Python, generating straight from _data/simple_icons.json may be worth considering.

I think a better idea though would be to just remove move _data/simple_icons.json to scripts so it is not bundled with the package. This would keep similar generation and remove the dependence on the filesystem. It also allows for quick enumeration over icons because it does not have to read any files.