__init__.py 文件源码

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

项目:girder_worker 作者: girder 项目源码 文件源码
def _inline_fetch(spec, **kwargs):
    taskInput = kwargs.get('task_input', {})
    target = taskInput.get('target', 'memory')
    if target == 'filepath':
        # Ensure we have a trailing slash
        tmpDir = os.path.join(kwargs['_tempdir'], '')

        if 'filename' in taskInput:
            filename = taskInput['filename']
            path = os.path.join(tmpDir, filename)
            with open(path, 'wb') as out:
                out.write(spec['data'])
        else:
            with tempfile.NamedTemporaryFile(
                    'wb', prefix=tmpDir, delete=False) as out:
                out.write(spec['data'])
                path = out.name

        return path
    elif target == 'memory':
        return spec['data']
    else:
        raise Exception('Invalid fetch target: ' + target)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号