# Path: il2fb/ds/airbridge/json.py
# class JSONEncoder(_json.JSONEncoder):
#     def default(self, obj):
# def object_decoder(obj):
# 
# Path: il2fb/ds/airbridge/typing.py

# 
# Path: il2fb/ds/airbridge/streaming/subscribers/base.py
# class PluggableStreamingSubscriber(StreamingSubscriber):
# 
#     def __init__(self, app):
#         self._app = app
# 
#     def plug_in(self) -> None:
#         pass
# 
#     async def wait_plugged(self) -> Awaitable[None]:
#         pass
# 
#     def unplug(self) -> None:
#         pass
# 
#     async def wait_unplugged(self) -> Awaitable[None]:
#         pass


import logging
from pathlib import Path
from typing import Any, Awaitable
from il2fb.ds.airbridge import json
from il2fb.ds.airbridge.typing import StringOrPath
from il2fb.ds.airbridge.streaming.subscribers.base import PluggableStreamingSubscriber

    async def write(self, s: str) -> Awaitable[None]:
        self._maybe_reopen()
        self._stream.write(s + '\n')
        self._stream.flush()

    def _maybe_reopen(self) -> None:
        try:
            stat = self._path.lstat()
        except FileNotFoundError:
            stat = None

        if (
            (stat is None) or
            (stat.st_dev != self._stat.st_dev) or
            (stat.st_ino != self._stat.st_ino)
        ):
            self.close()
            self.open()

    def unplug(self) -> None:
        try:
            self._stream.flush()
        finally:
            self._stream.close()


class JSONFileStreamingSink(TextFileStreamingSink):

    async def write(self, o: Any) -> Awaitable[None]:

# Path: il2fb/ds/airbridge/json.py
# class JSONEncoder(_json.JSONEncoder):
#     def default(self, obj):
# def object_decoder(obj):
# 
# Path: il2fb/ds/airbridge/typing.py

# 
# Path: il2fb/ds/airbridge/streaming/subscribers/base.py
# class PluggableStreamingSubscriber(StreamingSubscriber):
# 
#     def __init__(self, app):
#         self._app = app
# 
#     def plug_in(self) -> None:
#         pass
# 
#     async def wait_plugged(self) -> Awaitable[None]:
#         pass
# 
#     def unplug(self) -> None:
#         pass
# 
#     async def wait_unplugged(self) -> Awaitable[None]:
#         pass


# Path: il2fb/ds/airbridge/streaming/subscribers/file.py
import logging
from pathlib import Path
from typing import Any, Awaitable
from il2fb.ds.airbridge import json
from il2fb.ds.airbridge.typing import StringOrPath
from il2fb.ds.airbridge.streaming.subscribers.base import PluggableStreamingSubscriber


    async def write(self, s: str) -> Awaitable[None]:
        self._maybe_reopen()
        self._stream.write(s + '\n')
        self._stream.flush()

    def _maybe_reopen(self) -> None:
        try:
            stat = self._path.lstat()
        except FileNotFoundError:
            stat = None

        if (
            (stat is None) or
            (stat.st_dev != self._stat.st_dev) or
            (stat.st_ino != self._stat.st_ino)
        ):
            self.close()
            self.open()

    def unplug(self) -> None:
        try:
            self._stream.flush()
        finally:
            self._stream.close()


class JSONFileStreamingSink(TextFileStreamingSink):

    async def write(self, o: Any) -> Awaitable[None]:

        s = json.dumps(o)