26 lines
735 B
Python
26 lines
735 B
Python
import ptvp35
|
|
from rainbowadn.instrument import Instrumentation
|
|
|
|
__all__ = ('InstrumentDiskWrites', 'NightlyInstrumentation')
|
|
|
|
|
|
class InstrumentDiskWrites(Instrumentation):
|
|
def __init__(self, /):
|
|
super().__init__(ptvp35._File, 'write_to_disk_sync')
|
|
|
|
def on_write(self, line: str, /) -> None:
|
|
pass
|
|
|
|
def instrument(self, method, db, line, /):
|
|
self.on_write(line)
|
|
return method(db, line)
|
|
|
|
|
|
class NightlyInstrumentation(Instrumentation):
|
|
def __init__(self, target, methodname: str):
|
|
method = getattr(target, methodname)
|
|
if hasattr(method, '__non_nightly__'):
|
|
target = method
|
|
methodname = '__non_nightly__'
|
|
super().__init__(target, methodname)
|