Skip to content

Commit

Permalink
Make provider resources more general (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella authored Jun 26, 2024
1 parent 3c3c18e commit 097604c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/codemodder/providers.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
from abc import ABCMeta, abstractmethod
from collections import UserDict
from importlib.metadata import entry_points
from typing import Any

from codemodder.logging import logger


class BaseProvider(metaclass=ABCMeta):
name: str
_resource: str | None
_resource: Any | None

def __init__(self, name):
self.name = name
self._resource = self.load()

@abstractmethod
def load(self) -> str | None:
def load(self) -> Any | None:
pass

@property
def is_available(self) -> bool:
return self.resource is not None

@property
def resource(self) -> str:
def resource(self) -> Any:
if self._resource is None:
raise ValueError(f"Resource for provider {self.name} is not available")
return self._resource
Expand Down

0 comments on commit 097604c

Please sign in to comment.