@@ -78,8 +78,7 @@ def filename(self, trans):
7878 A subclass could override this in order to serve files from other
7979 disk locations based on some logic.
8080 """
81- filename = getattr (self , '_serverSideFilename' , None )
82- if filename is None :
81+ if (filename := getattr (self , '_serverSideFilename' , None )) is None :
8382 filename = trans .request ().serverSidePath ()
8483 self ._serverSideFilename = filename # cache it
8584 return filename
@@ -199,8 +198,7 @@ def serveContent(self, trans):
199198 print ('>> UnknownFileType.serveContent()' )
200199 print ('>> filename =' , filename )
201200 print ('>> size=' , fileSize )
202- fileDict = fileCache .get (filename )
203- if fileDict is not None and mtime != fileDict ['mtime' ]:
201+ if (fileDict := fileCache .get (filename )) is not None and mtime != fileDict ['mtime' ]:
204202 # Cache is out of date; clear it.
205203 if debug :
206204 print ('>> changed, clearing cache' )
@@ -241,8 +239,7 @@ def serveContent(self, trans):
241239 print ('>> sending directly' )
242240 numBytesSent = 0
243241 while numBytesSent < fileSize :
244- data = f .read (min (fileSize - numBytesSent , readBufferSize ))
245- if data == '' :
242+ if not (data := f .read (min (fileSize - numBytesSent , readBufferSize ))):
246243 break # unlikely, but safety first
247244 response .write (data )
248245 numBytesSent += len (data )
0 commit comments