Blender
V3.3
|
#include <Python.h>
#include <stddef.h>
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_blendfile_link_append.h"
#include "BKE_context.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "DNA_space_types.h"
#include "BLO_readfile.h"
#include "MEM_guardedalloc.h"
#include "bpy_capi_utils.h"
#include "bpy_library.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "RNA_access.h"
#include "bpy_rna.h"
Go to the source code of this file.
Classes | |
struct | BPy_Library |
struct | LibExitLappContextItemsIterData |
Macros | |
#define | USE_RNA_DATABLOCKS |
Functions | |
static PyObject * | bpy_lib_load (BPy_PropertyRNA *self, PyObject *args, PyObject *kwds) |
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, assets_only=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: string\n" " :arg link: When False reference to the original file is lost.\n" " :type link: bool\n" " :arg relative: When True the path is stored relative to the open blend file.\n" " :type relative: bool\n" " :arg assets_only: If True, only list data-blocks marked as assets.\n" " :type assets_only: 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, void *userdata) |
static PyObject * | bpy_lib_exit (BPy_Library *self, PyObject *UNUSED(args)) |
int | BPY_library_load_type_ready (void) |
Variables | |
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.c.
#define USE_RNA_DATABLOCKS |
Definition at line 43 of file bpy_library_load.c.
|
static |
Definition at line 231 of file bpy_library_load.c.
References BLI_linklist_freeN(), BLO_blendhandle_get_datablock_names(), counter, FILE_ASSETS_ONLY, l, names, BMLoop::next, and self.
Referenced by bpy_lib_enter().
|
static |
Definition at line 80 of file bpy_library_load.c.
References self.
|
static |
Definition at line 509 of file bpy_library_load.c.
References self.
|
static |
Definition at line 253 of file bpy_library_load.c.
References _bpy_names(), BPy_Library::abspath, BKE_idtype_idcode_is_linkable(), BKE_idtype_idcode_iter_step(), BKE_idtype_idcode_to_name_plural(), BKE_reports_clear(), BKE_reports_init(), BLI_strncpy(), BLO_blendhandle_from_file(), BPy_Library::blo_handle, bpy_lib_Type, BPy_reports_to_error(), BPy_Library::dict, BPy_Library::flag, INDEX_ID_MAX, NULL, PyTuple_SET_ITEMS, BPy_Library::relpath, BlendFileReadReport::reports, ret, RPT_STORE, self, and str.
|
static |
|
static |
Definition at line 400 of file bpy_library_load.c.
References BKE_blendfile_append(), BKE_blendfile_link(), BKE_blendfile_link_append_context_free(), 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_idtype_idcode_is_linkable(), BKE_idtype_idcode_iter_step(), BKE_idtype_idcode_to_name_plural(), BKE_main_id_tag_all(), BLO_blendhandle_close(), BLO_library_link_params_init(), LibraryLink_Params::bmain, bpy_lib_exit_lapp_context_items_cb(), bpy_lib_exit_warn_type(), FILE_LINK, LibraryLink_Params::id_tag_extra, ID_WS, LibExitLappContextItemsIterData::idcode, LIB_TAG_PRE_EXISTING, LIB_TAG_TEMP_MAIN, NULL, POINTER_FROM_INT, self, and size().
|
static |
Definition at line 353 of file bpy_library_load.c.
References BKE_blendfile_link_append_context_item_idcode_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, NULL, POINTER_AS_INT, LibExitLappContextItemsIterData::py_list_size, pyrna_struct_CreatePyObject(), and RNA_id_pointer_create().
Referenced by bpy_lib_exit().
|
static |
Definition at line 309 of file bpy_library_load.c.
References self.
Referenced by bpy_lib_exit_lapp_context_items_cb().
|
static |
|
static |
Definition at line 180 of file bpy_library_load.c.
References BKE_main_blendfile_path(), BLI_path_abs(), BLI_strncpy(), BPY_context_get(), bpy_lib_Type, CTX_data_main(), FILE_ASSETS_ONLY, FILE_LINK, FILE_RELPATH, INDEX_ID_MAX, NULL, PyC_ParseBool(), and ret.
int BPY_library_load_type_ready | ( | void | ) |
Definition at line 521 of file bpy_library_load.c.
References bpy_lib_Type.
Referenced by BPy_init_modules().
PyDoc_STRVAR | ( | bpy_lib_load_doc | , |
".. method:: load(filepath, link=False, relative=False, assets_only=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: string\n" " :arg link: When False reference to the original file is lost.\n" " :type link: bool\n" " :arg relative: When True the path is stored relative to the open blend file.\n" " :type relative: bool\n" " :arg assets_only: If | True, | ||
only list data-blocks marked as assets.\n" " :type assets_only:bool\n" | |||
) |
|
static |
Definition at line 73 of file bpy_library_load.c.
|
static |
Definition at line 86 of file bpy_library_load.c.
Referenced by bpy_lib_enter(), bpy_lib_load(), and BPY_library_load_type_ready().
PyMethodDef BPY_library_load_method_def |
Definition at line 514 of file bpy_library_load.c.
Referenced by BPY_rna_types_extend_capi().