Blender V5.3
bpy_library_load.cc File Reference
#include <Python.h>
#include <cstddef>
#include "BLI_linklist.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_path_utils.hh"
#include "BLI_string.hh"
#include "BLI_utildefines.hh"
#include "BKE_asset.hh"
#include "BKE_blender_version.h"
#include "BKE_blendfile_link_append.hh"
#include "BKE_context.hh"
#include "BKE_idtype.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_report.hh"
#include "DNA_space_types.h"
#include "BLO_readfile.hh"
#include "bpy_capi_utils.hh"
#include "bpy_library.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh"
#include "../generic/python_utildefines.hh"
#include "RNA_access.hh"
#include "bpy_rna.hh"

Go to the source code of this file.

Classes

struct  blender::BoolFlagPair
struct  blender::BPy_Library
struct  blender::LibExitLappContextItemsIterData

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define USE_RNA_DATABLOCKS

Functions

static PyObject * blender::make_library_info (BLODataBlockInfo &id_info)
static PyObject * blender::bpy_lib_load (BPy_PropertyRNA *self, PyObject *args, PyObject *kw)
static PyObject * blender::bpy_lib_enter (BPy_Library *self)
static PyObject * blender::bpy_lib_exit (BPy_Library *self, PyObject *args)
static PyObject * blender::bpy_lib_dir (BPy_Library *self)
static void blender::bpy_lib_dealloc (BPy_Library *self)
 blender::PyDoc_STRVAR (bpy_lib_load_doc, ".. method:: load(" "filepath, " "*, " "link=False, " "pack=False, " "relative=False, " "set_fake=False, " "recursive=False, " "reuse_local_id=False, " "assets_only=False, " "clear_asset_data=False, " "create_liboverrides=False, " "reuse_liboverrides=False, " "create_liboverrides_runtime=False)\n" "\n" " Returns a context manager which exposes a pair of library objects (input and output)\n" " on entering.\n" "\n" " The input contains the data-blocks available in the loaded blend-file library and should\n" " be treated as read-only.\n" " Data-block names added to the output are linked/appended when the context exits.\n" "\n" " Each library object contains:\n" " - Attributes matching ``bpy.data``, which are lists of strings representing linkable\n" " data-blocks.\n" " - A ``libraries`` attribute, which for the input is a list of all other libraries\n" " used by the loaded one, as named tuples (``filepath``, ``is_archive``). The\n" " filepath may be absolute, or relative to the loaded blend-file. The output\n" " ``libraries`` attribute is always ``None``.\n" " - A ``version`` attribute, representing the version of the loaded library blend-file\n" " (for the input) or the version of the current Blender (for the output).\n" "\n" " Notes:\n" " - Not all data-block types are linkable (e.g. WindowManager, Library, ...).\n" " - Packed linked data-blocks are not linkable and are not listed in the input\n" " ``libraries`` attribute.\n" "\n" " :param filepath: The path to a blend file.\n" " :type filepath: str | bytes\n" " :param link: When False reference to the original file is lost.\n" " :type link: bool\n" " :param pack: If True, and ``link`` is also True, pack linked data-blocks into the current " "blend-file.\n" " :type pack: bool\n" " :param relative: When True the path is stored relative to the open blend file.\n" " :type relative: bool\n" " :param set_fake: If True, set fake user on appended IDs.\n" " :type set_fake: bool\n" " :param recursive: If True, also make indirect dependencies of appended libraries local.\n" " :type recursive: bool\n" " :param reuse_local_id: If True," "try to re-use previously appended matching ID on new append.\n" " :type reuse_local_id: bool\n" " :param assets_only: If True, only list data-blocks marked as assets.\n" " :type assets_only: bool\n" " :param clear_asset_data: If True, " "clear the asset data on append (it is always kept for linked data).\n" " :type clear_asset_data: bool\n" " :param create_liboverrides: If True and ``link`` is True, liboverrides will\n" " be created for linked data.\n" " :type create_liboverrides: bool\n" " :param reuse_liboverrides: If True and ``create_liboverride`` is True,\n" " search for existing liboverride first.\n" " :type reuse_liboverrides: bool\n" " :param create_liboverrides_runtime: If True and ``create_liboverride`` is True,\n" " create (or search for existing) runtime liboverride.\n" " :type create_liboverrides_runtime: bool\n")
static PyObject * blender::_bpy_ids_info (BPy_Library *self, int blocktype)
static void blender::bpy_lib_exit_warn_idname (BPy_Library *self, const char *name_plural, const char *idname)
static void blender::bpy_lib_exit_warn_type (BPy_Library *self, PyObject *item)
static bool blender::bpy_lib_exit_lapp_context_items_cb (BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, LibExitLappContextItemsIterData &data)
int blender::BPY_library_load_type_ready ()
Internal Utilities
static uint32_t blender::bool_flag_pair_as_flag (const BoolFlagPair *bool_flags, int bool_flags_num)

Variables

static PyTypeObject blender::bpy_lib_LibraryType
static PyStructSequence_Field blender::bpy_lib_LibraryType_fields []
static PyStructSequence_Desc blender::bpy_lib_LibraryType_desc
static constexpr Py_ssize_t blender::bpy_library_dict_num = INDEX_ID_MAX + 1
static PyMethodDef blender::bpy_lib_methods []
static PyTypeObject blender::bpy_lib_Type

Detailed Description

This file exposed blend file library appending/linking to python, typically this would be done via RNA API but in this case a hand written Python API allows us to use Python's context manager (__enter__ and __exit__).

Everything here is exposed via bpy.data.libraries.load(...) which returns a context manager.

Definition in file bpy_library_load.cc.

Macro Definition Documentation

◆ USE_RNA_DATABLOCKS

#define USE_RNA_DATABLOCKS

Definition at line 46 of file bpy_library_load.cc.