Load a scene from a string

Hello,

For a project, I need to load a scene from python. I found https://docs.blender.org/api/2.80/bpy.ops.wm.html#bpy.ops.wm.open_mainfile but it needs an actual file.
On my project, i can’t create any physical file on the computer.

Is there a way to load a scene from a string?

If there is not, if I’m making a patch for blender, what is the probility to be accepted?

Thanks!

Not sure where the confusion is, the operator you mentioned already does exactly what you want. Where did you get the idea that it needs a file? It’s not even possible to pass a file to an operator because there isn’t a property type that would support that type of thing.

filepath ( string , ( optional , never None ) ) – File Path, Path to file

Sorry, i was not explicite enough.

You are right, the first paramater of the function is a string but it’s a file path, I want to give the actual content (of the file) directly.
I can’t use an intermediary, (my data are directly pull from a http request).

This seems like an easy problem to solve unless I’m missing something. You say you can’t create files on the computer you’re on but blender writes tons of temp files as part of it’s normal operation. why can’t you write a temp file to the same temp folder blender uses for swap data and then use the load operator?

What is your data?
You can create a scene with the data you get.

scene = bpy.data.scenes.new('scene name')
scene.any_attributes = 'what_you_need_from_your_data'

We could support loading a blend file from data - Blender has this internally BLO_read_from_memory. So this could be called from Python, taking bytes as it’s input.

Although this seems a fairly obscure use-case. For Blender this is only used for the default startup and preview data.