Fix #30698: python console nodetree paths were not accurate, now show ... like
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 10 Apr 2012 16:37:05 +0000 (16:37 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 10 Apr 2012 16:37:05 +0000 (16:37 +0000)
in some other cases to at least show these are not accurate.

source/blender/python/intern/bpy_rna.c

index 38ee3cf8f0a31df9d3c113ed6696a22145bdcaa4..175aada509456e899ceb9e02d1f1a9194e8ede18 100644 (file)
@@ -871,10 +871,17 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
                const char *path;
                path = RNA_path_from_ID_to_struct(&self->ptr);
                if (path) {
-                       ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
-                                                  BKE_idcode_to_name_plural(GS(id->name)),
-                                                  tmp_str,
-                                                  path);
+                       if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */
+                               ret = PyUnicode_FromFormat("bpy.data...%s",
+                                                                                  path);
+                       }
+                       else {
+                               ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
+                                                          BKE_idcode_to_name_plural(GS(id->name)),
+                                                          tmp_str,
+                                                          path);
+                       }
+
                        MEM_freeN((void *)path);
                }
                else { /* cant find, print something sane */
@@ -971,10 +978,17 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self)
 
        path = RNA_path_from_ID_to_property(&self->ptr, self->prop);
        if (path) {
-               ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
-                                          BKE_idcode_to_name_plural(GS(id->name)),
-                                          tmp_str,
-                                          path);
+               if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */
+                       ret = PyUnicode_FromFormat("bpy.data...%s",
+                                                                          path);
+               }
+               else {
+                       ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
+                                                  BKE_idcode_to_name_plural(GS(id->name)),
+                                                  tmp_str,
+                                              path);
+               }
+
                MEM_freeN((void *)path);
        }
        else { /* cant find, print something sane */