Fixes entry point loading compatibility

Handles backward compatibility for entry point loading by
catching AttributeError and applying an alternative method
for fetching downloaders in `pix360downloader`.
This commit is contained in:
Kumi 2024-11-15 11:23:19 +01:00
parent 421587c695
commit 0520b40095
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -57,10 +57,21 @@ class Loader:
downloaders = []
for entry_point in importlib.metadata.entry_points().get("pix360downloader", []):
try:
downloaders.append(entry_point.load())
except Exception as e:
print(f"Something went wrong trying to import {entry_point}: {e}")
try:
for entry_point in importlib.metadata.entry_points().get("pix360downloader", []):
try:
downloaders.append(entry_point.load())
except Exception as e:
print(f"Something went wrong trying to import {entry_point}: {e}")
except AttributeError:
for entry_point in importlib.metadata.entry_points().select(
group="pix360downloader"
):
try:
downloaders.append(entry_point.load())
except Exception as e:
print(f"Something went wrong trying to import {entry_point}: {e}"
)
return downloaders