# Path: fastavro/repository/base.py
# class AbstractSchemaRepository(ABC):
#     @abstractmethod
#     def load(self, name):
#         pass
# 
# class SchemaRepositoryError(Exception):
#     pass


import json
from os import path
from .base import AbstractSchemaRepository, SchemaRepositoryError



class FlatDictRepository(AbstractSchemaRepository):
    def __init__(self, path):
        self.path = path
        self.file_ext = "avsc"

    def load(self, name):
        file_path = path.join(self.path, f"{name}.{self.file_ext}")
        try:
            with open(file_path) as schema_file:
                return json.load(schema_file)
        except IOError as error:
            raise SchemaRepositoryError(
                f"Failed to load '{name}' schema",
            ) from error
        except json.decoder.JSONDecodeError as error:

# Path: fastavro/repository/base.py
# class AbstractSchemaRepository(ABC):
#     @abstractmethod
#     def load(self, name):
#         pass
# 
# class SchemaRepositoryError(Exception):
#     pass


# Path: fastavro/repository/flat_dict.py
import json
from os import path
from .base import AbstractSchemaRepository, SchemaRepositoryError




class FlatDictRepository(AbstractSchemaRepository):
    def __init__(self, path):
        self.path = path
        self.file_ext = "avsc"

    def load(self, name):
        file_path = path.join(self.path, f"{name}.{self.file_ext}")
        try:
            with open(file_path) as schema_file:
                return json.load(schema_file)
        except IOError as error:
            raise SchemaRepositoryError(
                f"Failed to load '{name}' schema",
            ) from error
        except json.decoder.JSONDecodeError as error:

            raise SchemaRepositoryError(