~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to source/blender/python/intern/bpy.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include <Python.h>
34
34
 
35
 
#include "bpy.h" 
36
 
#include "bpy_util.h" 
 
35
#include "RNA_types.h"
 
36
#include "RNA_access.h"
 
37
 
 
38
#include "BLI_path_util.h"
 
39
#include "BLI_string.h"
 
40
#include "BKE_bpath.h"
 
41
#include "BLI_utildefines.h"
 
42
 
 
43
#include "bpy.h"
 
44
#include "bpy_util.h"
37
45
#include "bpy_rna.h"
38
46
#include "bpy_app.h"
39
47
#include "bpy_props.h"
 
48
#include "bpy_library.h"
40
49
#include "bpy_operator.h"
41
50
 
42
 
#include "BLI_path_util.h"
43
 
#include "BLI_string.h"
44
 
#include "BLI_bpath.h"
45
 
#include "BLI_utildefines.h"
46
 
 
47
51
#include "BKE_main.h"
48
52
#include "BKE_global.h" /* XXX, G.main only */
49
53
#include "BKE_blender.h"
50
54
 
51
 
#include "RNA_access.h"
52
 
 
53
55
#include "MEM_guardedalloc.h"
54
56
 
55
57
/* external util modules */
92
94
        PyObject *item = PyUnicode_DecodeFSDefault(path_src);
93
95
        PyList_Append(list, item);
94
96
        Py_DECREF(item);
95
 
        return FALSE; /* never edits the path */
 
97
        return false; /* never edits the path */
96
98
}
97
99
 
98
100
PyDoc_STRVAR(bpy_blend_paths_doc,
114
116
        int flag = 0;
115
117
        PyObject *list;
116
118
 
117
 
        int absolute = FALSE;
118
 
        int packed =   FALSE;
119
 
        int local =    FALSE;
 
119
        int absolute = false;
 
120
        int packed   = false;
 
121
        int local    = false;
120
122
        static const char *kwlist[] = {"absolute", "packed", "local", NULL};
121
123
 
122
 
        if (!PyArg_ParseTupleAndKeywords(args, kw, "|ii:blend_paths",
123
 
                                         (char **)kwlist, &absolute, &packed))
 
124
        if (!PyArg_ParseTupleAndKeywords(args, kw, "|iii:blend_paths",
 
125
                                         (char **)kwlist, &absolute, &packed, &local))
124
126
        {
125
127
                return NULL;
126
128
        }
127
129
 
128
 
        if (absolute) flag |= BPATH_TRAVERSE_ABS;
129
 
        if (!packed)  flag |= BPATH_TRAVERSE_SKIP_PACKED;
130
 
        if (local)    flag |= BPATH_TRAVERSE_SKIP_LIBRARY;
 
130
        if (absolute) flag |= BKE_BPATH_TRAVERSE_ABS;
 
131
        if (!packed)  flag |= BKE_BPATH_TRAVERSE_SKIP_PACKED;
 
132
        if (local)    flag |= BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
131
133
 
132
134
        list = PyList_New(0);
133
135
 
134
 
        bpath_traverse_main(G.main, bpy_blend_paths_visit_cb, flag, (void *)list);
 
136
        BKE_bpath_traverse_main(G.main, bpy_blend_paths_visit_cb, flag, (void *)list);
135
137
 
136
138
        return list;
137
139
}
170
172
}
171
173
 
172
174
PyDoc_STRVAR(bpy_resource_path_doc,
173
 
".. function:: resource_path(type, major=2, minor=57)\n"
 
175
".. function:: resource_path(type, major=bpy.app.version[0], minor=bpy.app.version[1])\n"
174
176
"\n"
175
177
"   Return the base path for storing system files.\n"
176
178
"\n"
203
205
                return NULL;
204
206
        }
205
207
 
206
 
        path = BLI_get_folder_version(folder_id, (major * 100) + minor, FALSE);
 
208
        path = BLI_get_folder_version(folder_id, (major * 100) + minor, false);
207
209
 
208
210
        return PyUnicode_DecodeFSDefault(path ? path : "");
209
211
}
232
234
        return mod;
233
235
}
234
236
 
 
237
 
235
238
/******************************************************************************
236
239
 * Description: Creates the bpy module and adds it to sys.modules for importing
237
240
 ******************************************************************************/
238
241
void BPy_init_modules(void)
239
242
{
240
243
        extern BPy_StructRNA *bpy_context_module;
241
 
        extern int bpy_lib_init(PyObject *);
242
244
        PointerRNA ctx_ptr;
243
245
        PyObject *mod;
244
246
 
273
275
        PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type);
274
276
 
275
277
        /* needs to be first so bpy_types can run */
276
 
        bpy_lib_init(mod);
 
278
        BPY_library_module(mod);
277
279
 
278
280
        bpy_import_test("bpy_types");
279
281
        PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
280
282
        bpy_import_test("bpy_types");
281
 
        PyModule_AddObject(mod, "props", BPY_rna_props());      
 
283
        PyModule_AddObject(mod, "props", BPY_rna_props());
282
284
        /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
283
285
        PyModule_AddObject(mod, "ops", BPY_operator_module());
284
286
        PyModule_AddObject(mod, "app", BPY_app_struct());
292
294
 
293
295
        PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
294
296
 
 
297
        /* register bpy/rna classmethod callbacks */
 
298
        BPY_rna_register_cb();
 
299
 
295
300
        /* utility func's that have nowhere else to go */
296
301
        PyModule_AddObject(mod, meth_bpy_script_paths.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_script_paths, NULL));
297
302
        PyModule_AddObject(mod, meth_bpy_blend_paths.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_blend_paths, NULL));