import json
from abc import (
    ABC,
    abstractmethod
)

from settings import BASE_DIR


class Repository(ABC):
    @property
    @abstractmethod
    def filename(self) -> str:
        ...

    @property
    @abstractmethod
    def default_json(self) -> dict:
        ...

    def get_file(self):
        return BASE_DIR / self.filename

    def _persist_data(self, data: dict):
        with self.get_file().open("w") as buffer:
            json.dump(data, buffer, indent=2, default=str)

    def _read_data(self):
        file = self.get_file()
        if file.exists():
            return json.loads(file.read_text())
        return self.default_json

dbe5b7c7a2fd179f4d4753a04bfb742cd8d64dfb
<mask token>


class Repository(ABC):
    <mask token>

    @property
    @abstractmethod
    def default_json(self) ->dict:
        ...

    def get_file(self):
        return BASE_DIR / self.filename
    <mask token>

    def _read_data(self):
        file = self.get_file()
        if file.exists():
            return json.loads(file.read_text())
        return self.default_json

<mask token>


class Repository(ABC):

    @property
    @abstractmethod
    def filename(self) ->str:
        ...

    @property
    @abstractmethod
    def default_json(self) ->dict:
        ...

    def get_file(self):
        return BASE_DIR / self.filename
    <mask token>

    def _read_data(self):
        file = self.get_file()
        if file.exists():
            return json.loads(file.read_text())
        return self.default_json

<mask token>


class Repository(ABC):

    @property
    @abstractmethod
    def filename(self) ->str:
        ...

    @property
    @abstractmethod
    def default_json(self) ->dict:
        ...

    def get_file(self):
        return BASE_DIR / self.filename

    def _persist_data(self, data: dict):
        with self.get_file().open('w') as buffer:
            json.dump(data, buffer, indent=2, default=str)

    def _read_data(self):
        file = self.get_file()
        if file.exists():
            return json.loads(file.read_text())
        return self.default_json

import json
from abc import ABC, abstractmethod
from settings import BASE_DIR


class Repository(ABC):

    @property
    @abstractmethod
    def filename(self) ->str:
        ...

    @property
    @abstractmethod
    def default_json(self) ->dict:
        ...

    def get_file(self):
        return BASE_DIR / self.filename

    def _persist_data(self, data: dict):
        with self.get_file().open('w') as buffer:
            json.dump(data, buffer, indent=2, default=str)

    def _read_data(self):
        file = self.get_file()
        if file.exists():
            return json.loads(file.read_text())
        return self.default_json

import json
from abc import (
    ABC,
    abstractmethod
)

from settings import BASE_DIR


class Repository(ABC):
    @property
    @abstractmethod
    def filename(self) -> str:
        ...

    @property
    @abstractmethod
    def default_json(self) -> dict:
        ...

    def get_file(self):
        return BASE_DIR / self.filename

    def _persist_data(self, data: dict):
        with self.get_file().open("w") as buffer:
            json.dump(data, buffer, indent=2, default=str)

    def _read_data(self):
        file = self.get_file()
        if file.exists():
            return json.loads(file.read_text())
        return self.default_json
