Files
2125_GCE/glyphos/__pycache__/events.cpython-314.pyc
T

93 lines
8.8 KiB
Plaintext
Raw Normal View History

+
Ë0j6ãó²aRt0tRt^RIt^RIHtHtHtHtHtH t H
t
] R,t !RR]RR7t !RR4t
Rs]^kR R
ltR R ltR
RltR#)zÓGlyphOS Event System
Lightweight, in-process event bus for symbolic events.
Captures cognition-related events from Cognitive Kernel / LAIN.
Exposes glyph activation and resonance changes as first-class events.
N)ÚCallableÚDictÚListÚOptionalÚ TypedDictÚLiteralÚAnycó0a]tRt^toRtV3RltRtVtR#)ÚEventz%Event structure with optional fields.cóT<V^8„dQh/S[;R&S[;R&S[S[S[3,;R&#)éÚtypeÚ timestampÚpayload)Ú EventTypeÚfloatrÚstrr)ÚformatÚ
__classdict__s"€Ú&/home/dave/superdave/glyphos/events.pyÚ __annotate__ÚEvent.__annotate__s1ø‡á
ñÑññ‘#‘s(ò ó©N)Ú__name__Ú
__module__Ú __qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©rs@rr
r
sø‡Ùƒrr
F)Útotalcóªa]tRt^toRtV3RlRltV3RlRltV3RlRltV3RlR ltRV3R lR llt V3R
lRlt
RV3RlRllt Rt Vt
R
#)ÚEventBusz‡Lightweight in-process event bus.
Manages subscriptions and publishing of symbolic events.
Maintains event history for introspection.
có<V^8„dQhRR/#©r ÚreturnNr)rrs"€rrÚEventBus.__annotate__#sø€÷(˜(rc ó"/Vn.VnR#)zInitialize an empty EventBus.N)Ú _subscribersÚ_history©Úselfs&rÚ__init__ÚEventBus.__init__#sàLNˆÔØ%'ˆŽ
rcó@<V^8„dQhRS[RS[S[.R3,RR/#©r Ú
event_typeÚhandlerNr(©rrr
)rrs"€rrr)(s.ø€÷  :¡Ið Á%ÀÈ$ÀÕ8Oð :ÐTXñ :rc óºWP9d.VPV&W PV,9d%VPV,PV4R#R#)zœRegister a handler for a specific event type.
Args:
event_type: Type of event to listen for
handler: Callable that takes an Event and returns None
N)r+Úappend©r.r3r4s&&&rÚ subscribeÚEventBus.subscribe(sOð × .Ø,.ˆD× Ñ ˜jÑ ×+¨JÕ × Ñ ˜jÕ Ö  8rcó@<V^8„dQhRS[RS[S[.R3,RR/#r2r5)rrs"€rrr)5s.ø€÷ ñ ¡ið ¹(ÁEÀ7ÈDÀ=Õ:Qð ÐVZñ rc ó”WP9d&VPV,PV4R#R# \dR#i;i)z{Remove a handler if present.
Args:
event_type: Type of event to stop listening for
handler: The handler to remove
N)r+ÚremoveÚ
ValueErrorr8s&&&rÚ unsubscribeÚEventBus.unsubscribe5sGð × 
Ø×! *Õ4°WÖ +øôô
Úð
ús"8¸ AÁAcóB<V^8„dQhRS[RS[S[S[3,RS[/#©r r3rr(©rrrrr
)rrs"€rrr)Bs*ø€÷ñ¡)ð±d¹3Á¸8µnðÉñrc ó
RVR\P!4RV/pVPPV4WP9d$VPV,F pV!V4K V# \d pRp?K#Rp?ii;i)z»Create an Event, append to history, and invoke all handlers.
Args:
event_type: Type of event
payload: Event payload data
Returns:
The published Event (with timestamp added)
r
rrN)Útimer,r7r+Ú Exception)r.r3rÚeventr4Úes&&& rÚpublishÚEventBus.publishBs„ð
 œŸšØ 
ˆð
×јUÔ × ×,¨Z×8ðÙ˜E–Nñˆ øô õûðúsÁA,Á, BÁ=BNcóL<V^8„dQhRS[S[,RS[RS[S[,/#)r r3Úlimitr()rrÚintrr
)rrs"€rrr)as.ø€÷"¡9Õ9Ù=@ð
‰eñ9rc óÞVf%VP'dVPV)R#.#VPUu.uFq3PR4V8XgKVNK ppV'dWB)R#.#uupi)zÖReturn recent events, optionally filtered by type.
Args:
event_type: If provided, filter to only this event type
limit: Maximum number of events to return
Returns:
List of recent events (newest last)
Nr
)r,Úget)r.r3rLrHÚfiltereds&&& rÚ get_historyÚEventBus.get_historyasmð Ò à-1¯]¯]¨]4—=‘= %  Ð Ð $(§=¢=ÓP¡=˜a·E±E¸&³MÀZÑ4OŸ˜¡=ˆPß(08˜F˜ 8°bÐ 8ùòQs ·A*ÁA*có<V^8„dQhRR/#r'r)rrs"€rrr)usø€÷ñ˜tñrc ó.VnR#)zClear all stored events.N)r,r-s&rÚ
clear_historyÚEventBus.clear_historyus àˆŽ
rcó6<V^8„dQhRS[S[,RS[/#)r r3r()rrrM)rrs"€rrr)ys ø€÷  >©x¹ Õ/Bð >Écñ >rc ó¨Vf+\RVPP444#\VPP V.44#)zŠGet number of subscribers (for testing).
Args:
event_type: If provided, count for this type only
Returns:
Number of subscribers
c3ó8"TFp\V4xK R#5i©N)Úlen)Ú.0Úhandlerss& rÚ <genexpr>Ú0EventBus.get_subscriber_count.<locals>.<genexpr>ƒséÐPÑ5O¨”s˜8—}}Ó5Oùs)Úsumr+Úvaluesr[rO)r.r3s&&rÚget_subscriber_countÚEventBus.get_subscriber_countysHð Ò ÜÑP°T×5FÑ5F×5MÑ5MÔ5OÓ t×(×,¨Z¸Ó =r)r,r+)NédrZ)rrrrrr/r9r?rIrQrUrbr r!r"s@rr%r%sUø‡ñ÷ 
  ð ÷ð÷>9÷(ð÷   >rr%có$V^8„dQhR\/#)r r()r%)rs"rrrŒs÷ñ”xñrcó2\f \4s\#)z¬Get or create the singleton EventBus instance.
On first call, creates a new EventBus.
Returns same instance on subsequent calls.
Returns:
Singleton EventBus instance
)Ú _GLOBAL_BUSr%rrrÚ
get_event_busrhŒsôÒÜ“jˆ ä Ðrcó^V^8„dQhR\R\\\3,R\/#rBrC)rs"rrrs)÷

,”Yð
¬c´3¨h­ð
,¼Eñ
,rcó8\4pVPW4#)zÙConvenience function: publish an event on the global bus.