standard.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:membrane 作者: CrySyS 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号