Skip to content

Commit

Permalink
Merge pull request #259 from dgomes/master
Browse files Browse the repository at this point in the history
Changes backend library from simpleicons to simplepycons
  • Loading branch information
vigonotion authored Nov 18, 2024
2 parents ec7ac2f + b6431f8 commit 22cd906
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions custom_components/simpleicons/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import homeassistant.components.frontend
from homeassistant.components.frontend import _frontend_root
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.components.http.view import HomeAssistantView
from homeassistant.components.http import StaticPathConfig
from xml.dom.minidom import Document, parseString

from simpleicons.all import icons
import json
from simplepycons import all_icons

DOMAIN = "simpleicons"

Expand All @@ -14,17 +12,19 @@
ICON_URL = f"/{DOMAIN}/icons"
ICON_FILES = {"simpleicons": "si.js"}


class IconView(HomeAssistantView):
requires_auth = False

def __init__(self, slug):
self.url = ICON_URL + "/" + slug
self.icon = icons.get(slug)
icon = all_icons[slug]
dom = parseString(icon.raw_svg)
self.path = dom.getElementsByTagName("path")[0].getAttribute("d")

self.name = "Icon View"

async def get(self, request):
return self.json({"path": self.icon.path})
return self.json({"path": self.path })


class ListView(HomeAssistantView):
Expand All @@ -35,7 +35,7 @@ def __init__(self):
self.name = "Icons View"

async def get(self, request):
return self.json([{"name": icon} for icon in icons])
return self.json([{"name": icon.prototype.name} for icon in all_icons.__dict__.values()])


async def async_setup(hass, config):
Expand All @@ -51,8 +51,8 @@ async def async_setup(hass, config):

hass.http.register_view(ListView())

for icon in icons:
hass.http.register_view(IconView(icon))
for icon in all_icons.__dict__.values():
hass.http.register_view(IconView(icon.prototype.name))

if DOMAIN not in config:
return True
Expand Down
2 changes: 1 addition & 1 deletion custom_components/simpleicons/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"codeowners": [],
"requirements": [
"simpleicons==7.14.0"
"simplepycons==1!13.17.0"
],
"config_flow": true,
"version": "0.0.0"
Expand Down

0 comments on commit 22cd906

Please sign in to comment.