Blender V2.61 - r43446
|
#include <Python.h>
#include <stddef.h>
#include "BLO_readfile.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_library.h"
#include "BKE_idcode.h"
#include "BKE_report.h"
#include "BKE_context.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_linklist.h"
#include "BLI_path_util.h"
#include "BLI_listbase.h"
#include "DNA_space_types.h"
#include "bpy_util.h"
#include "bpy_rna.h"
#include "RNA_access.h"
Go to the source code of this file.
Classes | |
struct | BPy_Library |
Defines | |
#define | USE_RNA_DATABLOCKS |
Functions | |
static PyObject * | bpy_lib_load (PyObject *self, PyObject *args, PyObject *kwds) |
static PyObject * | bpy_lib_enter (BPy_Library *self, PyObject *args) |
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)\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") | |
static PyObject * | bpy_lib_load (PyObject *UNUSED(self), PyObject *args, PyObject *kwds) |
static PyObject * | _bpy_names (BPy_Library *self, int blocktype) |
static PyObject * | bpy_lib_enter (BPy_Library *self, PyObject *UNUSED(args)) |
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 PyObject * | bpy_lib_exit (BPy_Library *self, PyObject *UNUSED(args)) |
int | bpy_lib_init (PyObject *mod_par) |
Variables | |
static PyMethodDef | bpy_lib_methods [] |
static PyTypeObject | bpy_lib_Type |
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 pythons context manager (__enter__ and __exit__).
Everything here is exposed via bpy.data.libraries.load(...) which returns a context manager.
Definition in file bpy_library.c.
#define USE_RNA_DATABLOCKS |
Definition at line 35 of file bpy_library.c.
static PyObject* _bpy_names | ( | BPy_Library * | self, |
int | blocktype | ||
) | [static] |
Definition at line 210 of file bpy_library.c.
References BLI_linklist_free(), BLO_blendhandle_get_datablock_names(), addon::engine::free(), LinkNode::link, names, and LinkNode::next.
Referenced by bpy_lib_enter().
static void bpy_lib_dealloc | ( | BPy_Library * | self | ) | [static] |
Definition at line 86 of file bpy_library.c.
static PyObject * bpy_lib_dir | ( | BPy_Library * | self | ) | [static] |
Definition at line 420 of file bpy_library.c.
static PyObject* bpy_lib_enter | ( | BPy_Library * | self, |
PyObject * | UNUSEDargs | ||
) | [static] |
Definition at line 234 of file bpy_library.c.
References _bpy_names(), BPy_Library::abspath, BKE_idcode_is_linkable(), BKE_idcode_iter_step(), BKE_idcode_to_name_plural(), BKE_reports_clear(), BKE_reports_init(), BLI_strncpy(), BLO_blendhandle_from_file(), BPy_Library::blo_handle, BPy_reports_to_error(), BPy_Library::dict, BPy_Library::flag, i, NULL, BPy_Library::relpath, RPT_STORE, str, and TRUE.
static PyObject* bpy_lib_enter | ( | BPy_Library * | self, |
PyObject * | args | ||
) | [static] |
static PyObject* bpy_lib_exit | ( | BPy_Library * | self, |
PyObject * | args | ||
) | [static] |
static PyObject* bpy_lib_exit | ( | BPy_Library * | self, |
PyObject * | UNUSEDargs | ||
) | [static] |
Definition at line 318 of file bpy_library.c.
References BKE_idcode_is_linkable(), BKE_idcode_iter_step(), BKE_idcode_to_name_plural(), BKE_library_make_local(), BLO_blendhandle_close(), BLO_library_append_begin(), BLO_library_append_end(), BLO_library_append_named_part(), BPy_GetContext(), bpy_lib_exit_warn_idname(), bpy_lib_exit_warn_type(), CTX_data_main(), Main::curlib, err, FILE_LINK, flag_all_listbases_ids(), G, i, LIB_PRE_EXISTING, NULL, pyrna_struct_CreatePyObject(), recalc_all_library_objects(), RNA_id_pointer_create(), and size().
static void bpy_lib_exit_warn_idname | ( | BPy_Library * | self, |
const char * | name_plural, | ||
const char * | idname | ||
) | [static] |
Definition at line 288 of file bpy_library.c.
References simple_enum_gen::val.
Referenced by bpy_lib_exit().
static void bpy_lib_exit_warn_type | ( | BPy_Library * | self, |
PyObject * | item | ||
) | [static] |
Definition at line 303 of file bpy_library.c.
References simple_enum_gen::val.
Referenced by bpy_lib_exit().
int bpy_lib_init | ( | PyObject * | mod_par | ) |
Definition at line 426 of file bpy_library.c.
References bpy_lib_load(), and NULL.
Referenced by BPy_init_modules().
static PyObject* bpy_lib_load | ( | PyObject * | UNUSEDself, |
PyObject * | args, | ||
PyObject * | kwds | ||
) | [static] |
Definition at line 185 of file bpy_library.c.
References BPy_Library::abspath, BLI_path_abs(), BLI_strncpy(), BPy_Library::blo_handle, BPy_Library::dict, FILE_LINK, FILE_RELPATH, BPy_Library::flag, G, NULL, and BPy_Library::relpath.
static PyObject* bpy_lib_load | ( | PyObject * | self, |
PyObject * | args, | ||
PyObject * | kwds | ||
) | [static] |
Referenced by bpy_lib_init().
PyDoc_STRVAR | ( | bpy_lib_load_doc | , |
".. method:: load(filepath, link=False, relative=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" | |||
) |
PyMethodDef bpy_lib_methods[] [static] |
{ {"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS}, {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS}, {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS}, {NULL} }
Definition at line 79 of file bpy_library.c.
PyTypeObject bpy_lib_Type [static] |
Definition at line 93 of file bpy_library.c.