1010
1111from jupyter_events import EventLogger
1212from jupyter_ydoc import ydocs as YDOCS
13+ from ypy_websocket .stores import BaseYStore
1314from ypy_websocket .websocket_server import YRoom
14- from ypy_websocket .stores import BaseYStore , YDocNotFound
1515from ypy_websocket .yutils import write_var_uint
1616
1717from .loaders import FileLoader
@@ -111,14 +111,30 @@ async def initialize(self) -> None:
111111 if self .ystore is not None and await self .ystore .exists (self ._room_id ):
112112 # Load the content from the store
113113 await self .ystore .apply_updates (self ._room_id , self .ydoc )
114- self ._emit (LogLevel .INFO , "load" , "Content loaded from the store {}" .format (self .ystore .__class__ .__qualname__ ))
115- self .log .info ("Content in room %s loaded from the ystore %s" , self ._room_id , self .ystore .__class__ .__name__ ,)
114+ self ._emit (
115+ LogLevel .INFO ,
116+ "load" ,
117+ "Content loaded from the store {}" .format (
118+ self .ystore .__class__ .__qualname__
119+ ),
120+ )
121+ self .log .info (
122+ "Content in room %s loaded from the ystore %s" ,
123+ self ._room_id ,
124+ self .ystore .__class__ .__name__ ,
125+ )
116126
117127 # if YStore updates and source file are out-of-sync, resync updates with source
118128 if self ._document .source != model ["content" ]:
119- self ._emit (LogLevel .INFO , "initialize" , "The file is out-of-sync with the ystore." )
120- self .log .info ("Content in file %s is out-of-sync with the ystore %s" , self ._file .path , self .ystore .__class__ .__name__ ,)
121-
129+ self ._emit (
130+ LogLevel .INFO , "initialize" , "The file is out-of-sync with the ystore."
131+ )
132+ self .log .info (
133+ "Content in file %s is out-of-sync with the ystore %s" ,
134+ self ._file .path ,
135+ self .ystore .__class__ .__name__ ,
136+ )
137+
122138 doc = await self .ystore .get (self ._room_id )
123139 await self .ystore .remove (self ._room_id )
124140 version = 0
@@ -130,14 +146,15 @@ async def initialize(self) -> None:
130146
131147 else :
132148 self ._emit (LogLevel .INFO , "load" , "Content loaded from disk." )
133- self .log .info ("Content in room %s loaded from file %s" , self ._room_id , self ._file .path )
149+ self .log .info (
150+ "Content in room %s loaded from file %s" , self ._room_id , self ._file .path
151+ )
134152 self ._document .source = model ["content" ]
135153
136154 if self .ystore is not None :
137155 await self .ystore .create (self ._room_id , 0 )
138156 await self .ystore .encode_state_as_update (self ._room_id , self .ydoc )
139157
140-
141158 self ._last_modified = model ["last_modified" ]
142159 self ._document .dirty = False
143160 self .ready = True
0 commit comments