10
10
11
11
from jupyter_events import EventLogger
12
12
from jupyter_ydoc import ydocs as YDOCS
13
+ from ypy_websocket .stores import BaseYStore
13
14
from ypy_websocket .websocket_server import YRoom
14
- from ypy_websocket .stores import BaseYStore , YDocNotFound
15
15
from ypy_websocket .yutils import write_var_uint
16
16
17
17
from .loaders import FileLoader
@@ -111,14 +111,30 @@ async def initialize(self) -> None:
111
111
if self .ystore is not None and await self .ystore .exists (self ._room_id ):
112
112
# Load the content from the store
113
113
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
+ )
116
126
117
127
# if YStore updates and source file are out-of-sync, resync updates with source
118
128
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
+
122
138
doc = await self .ystore .get (self ._room_id )
123
139
await self .ystore .remove (self ._room_id )
124
140
version = 0
@@ -130,14 +146,15 @@ async def initialize(self) -> None:
130
146
131
147
else :
132
148
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
+ )
134
152
self ._document .source = model ["content" ]
135
153
136
154
if self .ystore is not None :
137
155
await self .ystore .create (self ._room_id , 0 )
138
156
await self .ystore .encode_state_as_update (self ._room_id , self .ydoc )
139
157
140
-
141
158
self ._last_modified = model ["last_modified" ]
142
159
self ._document .dirty = False
143
160
self .ready = True
0 commit comments