Selfie
Loading...
Searching...
No Matches
selfie_lib.WriteTracker Namespace Reference

Classes

class  CallLocation
 
class  CallStack
 
class  DiskWriteTracker
 
class  FirstWrite
 
class  InlineWriteTracker
 
class  SnapshotFileLayout
 
class  ToBeFileLazyBytes
 
class  ToBeFileWriteTracker
 
class  WriteTracker
 

Functions

CallStack recordCall (bool callerFileOnly)
 

Variables

 T = TypeVar("T")
 
 U = TypeVar("U")
 

Function Documentation

◆ recordCall()

CallStack selfie_lib.WriteTracker.recordCall ( bool  callerFileOnly)

Definition at line 100 of file WriteTracker.py.

100def recordCall(callerFileOnly: bool) -> CallStack:
101 stack_frames_raw = inspect.stack()
102 first_real_frame = next(
103 (
104 i
105 for i, x in enumerate(stack_frames_raw)
106 if x.frame.f_globals.get("__package__") != __package__
107 ),
108 None,
109 )
110 # filter to only the stack after the selfie-lib package
111 stack_frames = stack_frames_raw[first_real_frame:]
112
113 if callerFileOnly:
114 caller_file = stack_frames[0].filename
115 stack_frames = [
116 frame for frame in stack_frames if frame.filename == caller_file
117 ]
118
119 call_locations = [
120 CallLocation(frame.filename, frame.lineno) for frame in stack_frames
121 ]
122
123 location = call_locations[0]
124 rest_of_stack = call_locations[1:]
125
126 return CallStack(location, rest_of_stack)
127
128

Variable Documentation

◆ T

selfie_lib.WriteTracker.T = TypeVar("T")

Definition at line 14 of file WriteTracker.py.

◆ U

selfie_lib.WriteTracker.U = TypeVar("U")

Definition at line 15 of file WriteTracker.py.