sachinraja / simple-icons-py Goto Github PK
View Code? Open in Web Editor NEWpython wrapper for simple-icons
Home Page: https://pypi.org/project/simpleicons/
License: MIT License
python wrapper for simple-icons
Home Page: https://pypi.org/project/simpleicons/
License: MIT License
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. :)
Just discovered this nice tool! If I see that correctly svglib, reportlab and pillow are only used when converting to bitmaps, right? As these are pretty heavy dependencies (I know because I'm the original author of svglib ;) one might consider declaring them "extra" dependencies for pip. But I'm not familiar with poetry to know if it supports that.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/auto-update.yml
actions/checkout v3
oleksiyrudenko/gha-git-credentials v2-latest
actions/setup-python v4
snok/install-poetry v1.3.4
actions/cache v3
.github/workflows/ci.yml
actions/checkout v3
actions/setup-python v4
snok/install-poetry v1.3.4
actions/cache v3
pyproject.toml
poetry-core >=1.0.0
pyproject.toml
python ^3.8
reportlab ^3.6.3
Pillow ^9.2.0
svglib ^1.1.0
semantic-version ^2.8.5
requests ^2.26.0
GitPython ^3.1.24
pytest ^7.0.0
poethepoet ^0.26.0
pre-commit ^2.15.0
Pillow ^9.2.0
svglib ^1.1.0
reportlab ^3.5.68
Hi @sachinraja,
your github action is failing because simpleicons
had a major update to v7. Therefore, it is not updating anymore
It seems like the three functions get_xml()
, get_xml_bytes()
and get_str()
aren't working.
Minimal reproducible example:
from simpleicons.icon_xml import get_xml
github_icon = get_xml("github")
Throwing this error:
Traceback (most recent call last):
File "/home/fbernhart/.config/JetBrains/PyCharmCE2021.1/scratches/scratch_4.py", line 3, in <module>
github_icon = get_xml("github")
File "/mnt/Daten/Python/Python_Divers/venv/lib/python3.9/site-packages/simpleicons/icon_xml.py", line 41, in get_xml
tree = get_et(icon_name)
File "/mnt/Daten/Python/Python_Divers/venv/lib/python3.9/site-packages/simpleicons/icon_xml.py", line 28, in get_et
return ET.parse(f"simpleicons/icons/{icon_name.lower()}.svg")
File "/usr/local/lib/python3.9/xml/etree/ElementTree.py", line 1229, in parse
tree.parse(source, parser)
File "/usr/local/lib/python3.9/xml/etree/ElementTree.py", line 569, in parse
source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'simpleicons/icons/github.svg'
Process finished with exit code 1
The same happens for
from simpleicons.icon_xml import get_xml_bytes
github_bytes = get_xml_bytes("github")
and
from simpleicons.icon_xml import get_str
github_str = get_str("github")
Looking at the icon_xml.py
file, the error happens because you're trying to access simpleicons/icons/github.svg
. This might be working if you're testing your code locally and have your tests in the same directory, but it doesn't work while installing simpleicons as a package through pip. Because simpleicons/icons/github.svg
isn't located inside the current working directory (from where the script is called).
I'm not very familiar with opening a file from within a package, but I gave it a few tries and came up with this solution. It should work by replacing
return ET.parse(f"simpleicons/icons/{icon_name.lower()}.svg")
with
import sys
package_path = sys.modules[__package__].__path__[0]
return ET.parse(f"{package_path}/icons/{icon_name.lower()}.svg")
the same for the get_str()
function.
But let me know if you've got a better idea. ๐
From the next major release of simple-icons
(v11, releasing on May 26, 2024), We will begin removing third-party extensions from our README list that are not up to date with at least the previous major release.
For example, when v11 is released, we will remove any extensions that don't support v10.0.0 or higher.
There are two methods that prove most popular among other maintainers. It is up to you which you implement.
@latest
from a CDNProjects that use the CDN version of the project (jsDelivr/unpkg) can keep up to date simply by changing the version number in their code to @latest. That way - you're always using the most up to date version of the icon package.
Many of our third party contributors make use of GitHub actions, and a weekly CRON job to query that the version number of the main package has changed, and then update and build their own package. A great example of this is the DrawIO package by mondeja. The main package is released consistently on a Sunday - so we recommend running your CRON job on a Monday or Tuesday.
When you've got your extension running one of the above methods, drop us a Pull Request to update your version number on the README.
If you're in need of any support in implementing one of the above - please feel free to start a discussion or ask us on Discord.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.