Blender V2.61 - r43446
Classes | Defines | Functions | Variables

bpy_library.c File Reference

#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

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 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 Documentation

#define USE_RNA_DATABLOCKS

Definition at line 35 of file bpy_library.c.


Function Documentation

static PyObject* _bpy_names ( BPy_Library self,
int  blocktype 
) [static]
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]
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]
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]
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"   
)

Variable Documentation

PyMethodDef bpy_lib_methods[] [static]
Initial value:
 {
    {"__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.