forked from rc/aircox
tests: playlist_import, log_archiver, sound_stats.SoxStats
This commit is contained in:
@ -3,7 +3,7 @@ from collections import namedtuple
|
||||
import inspect
|
||||
|
||||
|
||||
__all__ = ("interface", "Interface")
|
||||
__all__ = ("interface", "Interface", "File")
|
||||
|
||||
|
||||
def interface(obj, funcs):
|
||||
@ -233,6 +233,7 @@ class Interface:
|
||||
def _irelease(self):
|
||||
"""Shortcut to `self._imeta.release`."""
|
||||
self._imeta.release()
|
||||
self._imeta.reset()
|
||||
|
||||
def _trace(self, *args, **kw):
|
||||
"""Shortcut to `self._imeta.get_trace`."""
|
||||
@ -266,3 +267,23 @@ class Interface:
|
||||
def __str__(self):
|
||||
iface = super().__str__()
|
||||
return f"{iface}::{self._imeta.target}"
|
||||
|
||||
|
||||
class File:
|
||||
def __init__(self, data=""):
|
||||
self.data = data
|
||||
|
||||
def read(self):
|
||||
return self.data
|
||||
|
||||
def write(self, data):
|
||||
self.data += data
|
||||
|
||||
def close(self):
|
||||
self.data = None
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *_, **__):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user