Skip to content

Commit

Permalink
Quick hack to workaround problems with missing package resources (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycpsu committed Apr 2, 2023
1 parent a52a18d commit 332888c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions streamglob/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@
from . import resources
from . import config

DEFAULT_BLANK_IMAGE_URI = """\
data://image/png;base64,\
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAA\
AAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=\
"""

try:
import importlib.resources as pkg_resources
except ImportError:
import importlib_resources as pkg_resources

with pkg_resources.path(resources, "css") as css_path:
globals()["CSS_PATH"] = os.path.join(css_path, "body.css")
try:
with pkg_resources.path(resources, "css") as css_path:
globals()["CSS_PATH"] = os.path.join(css_path, "body.css")
except FileNotFoundError:
# FIXME: some users are having errors finding package resources
globals()["CSS_PATH"] = None

with pkg_resources.path(resources, "images") as image_path:
globals()["BLANK_IMAGE_URI"] = os.path.join(image_path, "video.png")
try:
with pkg_resources.path(resources, "images") as image_path:
globals()["BLANK_IMAGE_URI"] = os.path.join(image_path, "video.png")
except FileNotFoundError:
globals()["BLANK_IMAGE_URI"] = DEFAULT_BLANK_IMAGE_URI


MEDIA_URI_RE=re.compile("uri=(.*)=\.")
Expand Down

0 comments on commit 332888c

Please sign in to comment.