def reload_file(self, path):
def assign_used_file():
self.currentPath = path
self.fname = self.used_files[path]['fname']
self.name = self.used_files[path]['fname']
self.mode = self.used_files[path]['mode']
self.fhandle = self.used_files[path]['fhandle']
self.fhandle.seek(0, 2)
self.fsize = self.used_files[path]['fsize']
if path in self.used_files:
if self.currentPath == path:
return
assign_used_file()
else:
debug.debug('read from file: ' + path)
path_name = urllib.url2pathname(path)
if not os.path.exists(path_name):
debug.warning('File not exist: ' + path + ' Returning zero bytes..')
currentPath = 'ZERO'
return
# assert os.path.exists(path_name), 'Filename must be specified and exist'
self.used_files[path]['fname'] = os.path.abspath(path_name)
self.used_files[path]['mode'] = 'rb'
if self._config.WRITE:
self.used_files[path]['mode'] += '+'
self.used_files[path]['fhandle'] = open(self.used_files[path]['fname'], self.used_files[path]['mode'])
self.used_files[path]['fsize'] = self.fhandle.tell()
assign_used_file()
评论列表
文章目录