|
Blender V5.0
|
#include <Python.h>#include <cstddef>#include "BLI_linklist.h"#include "BLI_math_vector_types.hh"#include "BLI_path_utils.hh"#include "BLI_string.h"#include "BLI_utildefines.h"#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 | BoolFlagPair |
| struct | BPy_Library |
| struct | LibExitLappContextItemsIterData |
Macros | |
| #define | USE_RNA_DATABLOCKS |
Functions | |
| static PyObject * | bpy_lib_load (BPy_PropertyRNA *self, PyObject *args, PyObject *kw) |
| static PyObject * | bpy_lib_enter (BPy_Library *self) |
| static PyObject * | bpy_lib_exit (BPy_Library *self, PyObject *args) |
| static PyObject * | bpy_lib_dir (BPy_Library *self) |
| static void | bpy_lib_dealloc (BPy_Library *self) |
| PyDoc_STRVAR (bpy_lib_load_doc, ".. method:: load(" "filepath, " "*, " "link=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 2 library objects on entering.\n" " Each object has attributes matching bpy.data which are lists of strings to be linked.\n" "\n" " :arg filepath: The path to a blend file.\n" " :type filepath: str | bytes\n" " :arg link: When False reference to the original file is lost.\n" " :type link: bool\n" " :arg pack: If True, and ``link`` is also True, pack linked data-blocks into the current " "blend-file.\n" " :type pack: bool\n" " :arg relative: When True the path is stored relative to the open blend file.\n" " :type relative: bool\n" " :arg set_fake: If True, set fake user on appended IDs.\n" " :type set_fake: bool\n" " :arg recursive: If True, also make indirect dependencies of appended libraries local.\n" " :type recursive: bool\n" " :arg reuse_local_id: If True," "try to re-use previously appended matching ID on new append.\n" " :type reuse_local_id: bool\n" " :arg assets_only: If True, only list data-blocks marked as assets.\n" " :type assets_only: bool\n" " :arg 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" " :arg create_liboverrides: If True and ``link`` is True, liboverrides will\n" " be created for linked data.\n" " :type create_liboverrides: bool\n" " :arg reuse_liboverrides: If True and ``create_liboverride`` is True,\n" " search for existing liboverride first.\n" " :type reuse_liboverrides: bool\n" " :arg 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 * | _bpy_names (BPy_Library *self, int blocktype) |
| static void | bpy_lib_exit_warn_idname (BPy_Library *self, const char *name_plural, const char *idname) |
| static void | bpy_lib_exit_warn_type (BPy_Library *self, PyObject *item) |
| static bool | bpy_lib_exit_lapp_context_items_cb (BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, LibExitLappContextItemsIterData &data) |
| int | BPY_library_load_type_ready () |
Internal Utilities | |
| static uint32_t | bool_flag_pair_as_flag (const BoolFlagPair *bool_flags, int bool_flags_num) |
Variables | |
| static constexpr Py_ssize_t | bpy_library_dict_num = INDEX_ID_MAX + 1 |
| static PyMethodDef | bpy_lib_methods [] |
| static PyTypeObject | bpy_lib_Type |
| PyMethodDef | BPY_library_load_method_def |
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.
| #define USE_RNA_DATABLOCKS |
Definition at line 45 of file bpy_library_load.cc.
|
static |
Definition at line 452 of file bpy_library_load.cc.
References BLI_linklist_freeN(), BLO_blendhandle_get_datablock_names(), FILE_ASSETS_ONLY, i, l, and self.
Referenced by bpy_lib_enter().
|
static |
Definition at line 60 of file bpy_library_load.cc.
References BLI_assert, BoolFlagPair::flag, flag, and i.
Referenced by bpy_lib_load().
|
static |
Definition at line 144 of file bpy_library_load.cc.
References self.
|
static |
Definition at line 785 of file bpy_library_load.cc.
References self.
|
static |
Definition at line 470 of file bpy_library_load.cc.
References _bpy_names(), BPy_Library::abspath, BKE_idtype_idcode_is_linkable(), BKE_idtype_idcode_iter_step(), BKE_idtype_idcode_to_name_plural(), BKE_LIBLINK_OVERRIDE_INIT, BKE_reports_clear(), BKE_reports_init(), BLENDER_FILE_SUBVERSION, BLENDER_FILE_VERSION, BLI_assert, BLO_blendhandle_from_file(), BLO_blendhandle_get_version(), BPy_Library::blo_handle, bpy_lib_Type, bpy_library_dict_num, BPy_reports_to_error(), BPy_Library::create_liboverrides, BPy_Library::dict, BPy_Library::flag, i, BPy_Library::liboverride_flags, Py_DECREF(), PyC_Tuple_PackArray_I32(), PyTuple_SET_ITEMS, BPy_Library::relpath, BlendFileReadReport::reports, ret, RPT_PRINT_HANDLED_BY_OWNER, RPT_STORE, self, str, STRNCPY(), and UNUSED_VARS_NDEBUG.
|
static |
Definition at line 655 of file bpy_library_load.cc.
References BKE_blendfile_append(), BKE_blendfile_link(), BKE_blendfile_link_append_context_finalize(), BKE_blendfile_link_append_context_free(), BKE_blendfile_link_append_context_init_done(), BKE_blendfile_link_append_context_item_add(), BKE_blendfile_link_append_context_item_foreach(), BKE_blendfile_link_append_context_item_library_index_enable(), BKE_blendfile_link_append_context_library_add(), BKE_blendfile_link_append_context_new(), BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT, BKE_blendfile_link_pack(), BKE_blendfile_override(), BKE_idtype_idcode_is_linkable(), BKE_idtype_idcode_iter_step(), BKE_idtype_idcode_to_name_plural(), BKE_main_id_tag_all(), BKE_reports_free(), BLI_assert, BLO_LIBLINK_PACK, BLO_library_link_params_init(), bpy_lib_exit_lapp_context_items_cb(), bpy_lib_exit_warn_type(), FILE_LINK, i, ID_TAG_PRE_EXISTING, ID_TAG_TEMP_MAIN, ID_WS, LibExitLappContextItemsIterData::idcode, POINTER_FROM_INT, Py_DECREF(), LibExitLappContextItemsIterData::py_library, LibExitLappContextItemsIterData::py_list, LibExitLappContextItemsIterData::py_list_size, self, and size().
|
static |
Definition at line 603 of file bpy_library_load.cc.
References BKE_blendfile_link_append_context_item_idcode_get(), BKE_blendfile_link_append_context_item_liboverrideid_get(), BKE_blendfile_link_append_context_item_newid_get(), BKE_blendfile_link_append_context_item_userdata_get(), BKE_idtype_idcode_to_name_plural(), BLI_assert, bpy_lib_exit_warn_idname(), data, POINTER_AS_INT, Py_DECREF(), pyrna_struct_CreatePyObject(), and RNA_id_pointer_create().
Referenced by bpy_lib_exit().
|
static |
Definition at line 557 of file bpy_library_load.cc.
References self.
Referenced by bpy_lib_exit_lapp_context_items_cb().
|
static |
|
static |
Definition at line 252 of file bpy_library_load.cc.
References BKE_LIBLINK_OVERRIDE_CREATE_RUNTIME, BKE_LIBLINK_OVERRIDE_USE_EXISTING_LIBOVERRIDES, BKE_main_blendfile_path(), BLI_path_abs(), BLI_path_cmp, BLI_path_normalize(), BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR, BLO_LIBLINK_APPEND_LOCAL_ID_REUSE, BLO_LIBLINK_APPEND_RECURSIVE, BLO_LIBLINK_APPEND_SET_FAKEUSER, BLO_LIBLINK_PACK, bool_flag_pair_as_flag(), BPY_context_get(), bpy_lib_Type, bpy_library_dict_num, CTX_data_main(), FILE_ASSETS_ONLY, FILE_LINK, FILE_MAX, FILE_RELPATH, PY_ARG_PARSER_HEAD_COMPAT, PyC_ParseBool(), PyC_ParseUnicodeAsBytesAndSize(), ret, self, STRNCPY(), PyC_UnicodeAsBytesAndSize_Data::value, and PyC_UnicodeAsBytesAndSize_Data::value_coerce.
| int BPY_library_load_type_ready | ( | ) |
Definition at line 815 of file bpy_library_load.cc.
References bpy_lib_Type.
Referenced by BPy_init_modules().
| PyDoc_STRVAR | ( | bpy_lib_load_doc | , |
| ".. method:: load(" "filepath, " "*, " "link=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 2 library objects on entering.\n" " Each object has attributes matching bpy.data which are lists of strings to be linked.\n" "\n" " :arg filepath: The path to a blend file.\n" " :type filepath: str | bytes\n" " :arg link: When False reference to the original file is lost.\n" " :type link: bool\n" " :arg pack: If | True, | ||
| and ``link`` is also | True, | ||
| pack linked data-blocks into the current " "blend-file.\n" " :type pack:bool\n" " :arg relative:When True the path is stored relative to the open blend file.\n" " :type relative:bool\n" " :arg set_fake:If | True, | ||
| set fake user on appended IDs.\n" " :type set_fake:bool\n" " :arg recursive:If | True, | ||
| also make indirect dependencies of appended libraries local.\n" " :type recursive:bool\n" " :arg reuse_local_id:If | True, | ||
| " "try to re-use previously appended matching ID on new append.\n" " :type reuse_local_id:bool\n" " :arg assets_only:If | True, | ||
| only list data-blocks marked as assets.\n" " :type assets_only:bool\n" " :arg 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" " :arg create_liboverrides:If True and ``link`` is | True, | ||
| liboverrides will\n" " be created for linked data.\n" " :type create_liboverrides:bool\n" " :arg reuse_liboverrides:If True and ``create_liboverride`` is | True, | ||
| \n" " search for existing liboverride first.\n" " :type reuse_liboverrides:bool\n" " :arg 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 |
Definition at line 129 of file bpy_library_load.cc.
|
static |
Definition at line 150 of file bpy_library_load.cc.
Referenced by bpy_lib_enter(), bpy_lib_load(), and BPY_library_load_type_ready().
|
staticconstexpr |
The size to pre-allocate BPy_Library::dict Add +1 for the "version".
Definition at line 77 of file bpy_library_load.cc.
Referenced by bpy_lib_enter(), and bpy_lib_load().
| PyMethodDef BPY_library_load_method_def |
Definition at line 800 of file bpy_library_load.cc.
Referenced by BPY_rna_types_extend_capi().