# Path: fimfarchive/utils.py
# class JayWalker:
#     """
#     Walker for JSON objects.
#     """
# 
#     def walk(self, data) -> None:
#         """
#         Walks the attributes of a JSON object.
# 
#         Args:
#             data: The object to walk.
#         """
#         iterator: Iterator
# 
#         if isinstance(data, dict):
#             iterator = iter(data.items())
#         elif isinstance(data, list):
#             iterator = enumerate(data)
#         else:
#             return
# 
#         for key, value in iterator:
#             self.handle(data, key, value)
# 
#     def handle(self, data, key, value) -> None:
#         """
#         Handles a single JSON entry.
# 
#         Args:
#             data: The current object.
#             key: The key of the entry.
#             value: The value of the entry.
#         """
#         self.walk(value)


import json
import importlib_resources as resources
import pytest
from json import JSONDecodeError
from os import environ
from pathlib import Path
from typing import Any, ContextManager, Dict, Iterator, Optional, Union, Type
from _pytest.fixtures import FixtureRequest
from requests import Session, Response
from requests.sessions import PreparedRequest
from requests_mock import Mocker
from fimfarchive.utils import JayWalker
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#






__all__ = (
    'responses',
)


NAMESPACE = 'responses'


class Recorder(ContextManager['Recorder']):
    """
    Records responses for mocking.
    """

    def __init__(self, path: Path) -> None:
        """
        Constructor.

        Args:
            path: File to record to.
        """
        self.original = Session.send
        self.responses: Dict = dict()

# Path: fimfarchive/utils.py
# class JayWalker:
#     """
#     Walker for JSON objects.
#     """
# 
#     def walk(self, data) -> None:
#         """
#         Walks the attributes of a JSON object.
# 
#         Args:
#             data: The object to walk.
#         """
#         iterator: Iterator
# 
#         if isinstance(data, dict):
#             iterator = iter(data.items())
#         elif isinstance(data, list):
#             iterator = enumerate(data)
#         else:
#             return
# 
#         for key, value in iterator:
#             self.handle(data, key, value)
# 
#     def handle(self, data, key, value) -> None:
#         """
#         Handles a single JSON entry.
# 
#         Args:
#             data: The current object.
#             key: The key of the entry.
#             value: The value of the entry.
#         """
#         self.walk(value)


# Path: tests/fixtures/responses.py
import json
import importlib_resources as resources
import pytest
from json import JSONDecodeError
from os import environ
from pathlib import Path
from typing import Any, ContextManager, Dict, Iterator, Optional, Union, Type
from _pytest.fixtures import FixtureRequest
from requests import Session, Response
from requests.sessions import PreparedRequest
from requests_mock import Mocker
from fimfarchive.utils import JayWalker

# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#






__all__ = (
    'responses',
)


NAMESPACE = 'responses'


class Recorder(ContextManager['Recorder']):
    """
    Records responses for mocking.
    """

    def __init__(self, path: Path) -> None:
        """
        Constructor.

        Args:
            path: File to record to.
        """
        self.original = Session.send
        self.responses: Dict = dict()

        self.walker: Optional[JayWalker] = None