From 9f2e845181e0828124b3c29519a82b38293291f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Jan 2013 09:53:56 +0000 Subject: code cleanup: use BMW_begin insode for loops body. --- doc/python_api/examples/bpy.types.AddonPreferences.1.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc') diff --git a/doc/python_api/examples/bpy.types.AddonPreferences.1.py b/doc/python_api/examples/bpy.types.AddonPreferences.1.py index 08de6f4f5a9..73f90acb3fa 100644 --- a/doc/python_api/examples/bpy.types.AddonPreferences.1.py +++ b/doc/python_api/examples/bpy.types.AddonPreferences.1.py @@ -17,6 +17,8 @@ from bpy.props import StringProperty, IntProperty, BoolProperty class ExampleAddonPreferences(AddonPreferences): + # this must match the addon name, use '__package__' + # when defining this in a submodule of a python package. bl_idname = __name__ filepath = StringProperty( -- cgit v1.2.3 From 769ab3eed81e8b14dff46af7ca28e2b70a7aac41 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Jan 2013 23:17:45 +0000 Subject: code cleanup: - cycles ui used 'cscene' for scene.cycles and scene.cycles_curves - style cleanup --- doc/python_api/examples/bpy.props.5.py | 12 ++++--- doc/python_api/examples/bpy.types.UIList.py | 2 +- doc/python_api/rst_from_bmesh_opdefines.py | 50 ++++++++++++++--------------- doc/python_api/sphinx_doc_gen.py | 6 ++-- 4 files changed, 37 insertions(+), 33 deletions(-) (limited to 'doc') diff --git a/doc/python_api/examples/bpy.props.5.py b/doc/python_api/examples/bpy.props.5.py index e49d0f2a0a0..1f61e33c30f 100644 --- a/doc/python_api/examples/bpy.props.5.py +++ b/doc/python_api/examples/bpy.props.5.py @@ -16,6 +16,7 @@ import bpy def get_float(self): return self["testprop"] + def set_float(self, value): self["testprop"] = value @@ -36,6 +37,7 @@ bpy.types.Scene.test_date = bpy.props.StringProperty(get=get_date) def get_array(self): return (True, self["somebool"]) + def set_array(self, values): self["somebool"] = values[0] and values[1] @@ -51,10 +53,12 @@ test_items = [ ("YELLOW", "Red", "", 4), ] + def get_enum(self): import random return random.randint(1, 4) + def set_enum(self, value): print("setting value", value) @@ -66,16 +70,16 @@ bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enu scene = bpy.context.scene scene.test_float = 12.34 -print (scene.test_float) +print(scene.test_float) scene.test_array = (True, False) -print ([x for x in scene.test_array]) +print([x for x in scene.test_array]) #scene.test_date = "blah" # this would fail, property is read-only -print (scene.test_date) +print(scene.test_date) scene.test_enum = 'BLUE' -print (scene.test_enum) +print(scene.test_enum) # >>> 12.34000015258789 diff --git a/doc/python_api/examples/bpy.types.UIList.py b/doc/python_api/examples/bpy.types.UIList.py index f2017e3883d..a37bbff726a 100644 --- a/doc/python_api/examples/bpy.types.UIList.py +++ b/doc/python_api/examples/bpy.types.UIList.py @@ -86,4 +86,4 @@ def unregister(): if __name__ == "__main__": - register() \ No newline at end of file + register() diff --git a/doc/python_api/rst_from_bmesh_opdefines.py b/doc/python_api/rst_from_bmesh_opdefines.py index c1b6643389d..3776ef7ce56 100644 --- a/doc/python_api/rst_from_bmesh_opdefines.py +++ b/doc/python_api/rst_from_bmesh_opdefines.py @@ -65,10 +65,10 @@ def main(): fsrc = open(FILE_OP_DEFINES_C, 'r', encoding="utf-8") blocks = [] - + is_block = False is_comment = False # /* global comments only */ - + comment_ctx = None block_ctx = None @@ -82,7 +82,7 @@ def main(): elif l.strip().startswith("/*"): is_comment = True comment_ctx = [] - + if is_block: if l.strip().startswith("//"): pass @@ -93,11 +93,11 @@ def main(): l = l[:cpp_comment] block_ctx.append(l) - + if l.strip() == "};": is_block = False comment_ctx = None - + if is_comment: c_comment_start = l.find("/*") if c_comment_start != -1: @@ -113,7 +113,6 @@ def main(): fsrc.close() del fsrc - # namespace hack vars = ( "BMO_OP_SLOT_ELEMENT_BUF", @@ -124,7 +123,7 @@ def main(): "BMO_OP_SLOT_VEC", "BMO_OP_SLOT_PTR", "BMO_OP_SLOT_MAPPING", - + "BMO_OP_SLOT_SUBTYPE_MAP_ELEM", "BMO_OP_SLOT_SUBTYPE_MAP_BOOL", "BMO_OP_SLOT_SUBTYPE_MAP_INT", @@ -157,23 +156,23 @@ def main(): for comment, b in blocks: # magic, translate into python b[0] = b[0].replace("static BMOpDefine ", "") - + for i, l in enumerate(b): l = l.strip() l = l.replace("{", "(") l = l.replace("}", ")") - + if l.startswith("/*"): l = l.replace("/*", "'''own <") else: l = l.replace("/*", "'''inline <") l = l.replace("*/", ">''',") - + # exec func. eg: bmo_rotate_edges_exec, if l.startswith("bmo_") and l.endswith("_exec,"): l = "None," b[i] = l - + #for l in b: # print(l) @@ -182,7 +181,7 @@ def main(): "__file__": "generated", "__name__": "__main__", } - + global_namespace.update(vars_dict) text_a, text_b = text.split("=", 1) @@ -191,7 +190,6 @@ def main(): # print(global_namespace["result"]) blocks_py.append((comment, global_namespace["result"])) - # --------------------- # Now convert into rst. fout = open(OUT_RST, 'w', encoding="utf-8") @@ -217,7 +215,7 @@ def main(): args_out_index[:] = [i for (i, a) in enumerate(args_out) if type(a) == tuple] fw(".. function:: %s(bm, %s)\n\n" % (b[0], ", ".join([args_in[i][0] for i in args_in_index]))) - + # -- wash the comment comment_washed = [] for i, l in enumerate(comment): @@ -236,7 +234,6 @@ def main(): fw("\n") # -- done - # get the args def get_args_wash(args, args_index, is_ret): args_wash = [] @@ -268,7 +265,7 @@ def main(): comment_next = comment_next[8:-1] # strip inline <...> else: comment_next = "" - + comment = "" if comment_prev: comment += comment_prev.strip() @@ -304,18 +301,21 @@ def main(): elif tp == BMO_OP_SLOT_ELEMENT_BUF: assert(tp_sub is not None) - + ls = [] - if tp_sub & BM_VERT: ls.append(":class:`bmesh.types.BMVert`") - if tp_sub & BM_EDGE: ls.append(":class:`bmesh.types.BMEdge`") - if tp_sub & BM_FACE: ls.append(":class:`bmesh.types.BMFace`") + if tp_sub & BM_VERT: + ls.append(":class:`bmesh.types.BMVert`") + if tp_sub & BM_EDGE: + ls.append(":class:`bmesh.types.BMEdge`") + if tp_sub & BM_FACE: + ls.append(":class:`bmesh.types.BMFace`") assert(ls) # must be at least one if tp_sub & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE: tp_str = "/".join(ls) else: tp_str = ("list of (%s)" % ", ".join(ls)) - + del ls elif tp == BMO_OP_SLOT_MAPPING: if tp_sub & BMO_OP_SLOT_SUBTYPE_MAP_EMPTY: @@ -356,21 +356,21 @@ def main(): fw(" :arg %s: %s\n" % (name, comment)) fw(" :type %s: %s\n" % (name, tp)) - + if args_out_wash: fw(" :return:\n\n") - + for (name, tp, comment) in args_out_wash: assert(name.endswith(".out")) name = name[:-4] fw(" - ``%s``: %s\n\n" % (name, comment)) fw(" **type** %s\n" % tp) - + fw("\n") fw(" :rtype: dict with string keys\n") fw("\n\n") - + fout.close() del fout print(OUT_RST) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index af6ddac937e..7457ae02d6c 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -612,10 +612,10 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True): ''' function or class method to sphinx ''' - + if type(py_func) == type(bpy.types.Space.draw_handler_add): return - + arg_str = inspect.formatargspec(*inspect.getargspec(py_func)) if not is_class: @@ -984,6 +984,7 @@ context_type_map = { "world": ("World", False), } + def pycontext2sphinx(basepath): # Only use once. very irregular @@ -1011,7 +1012,6 @@ def pycontext2sphinx(basepath): "sequencer_context_dir", ) - unique = set() blend_cdll = ctypes.CDLL("") for ctx_str in context_strings: -- cgit v1.2.3 From 97d8e34d6189fd0bf47cbed24412e96c7575dabe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Jan 2013 06:41:12 +0000 Subject: correct addon tutorial section on keymap register/unregister and add label next to image color-depth option. having buttons labelled [8, 16] on their own is not very meaningful. --- doc/python_api/rst/info_tutorial_addon.rst | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/python_api/rst/info_tutorial_addon.rst b/doc/python_api/rst/info_tutorial_addon.rst index 2a101041227..5637cf2f638 100644 --- a/doc/python_api/rst/info_tutorial_addon.rst +++ b/doc/python_api/rst/info_tutorial_addon.rst @@ -486,16 +486,14 @@ using :kbd:`Ctrl-Shift-Space` as the key shortcut to activate it. kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True) kmi.properties.total = 4 - addon_keymaps.append(km) + addon_keymaps.append((km, kmi)) def unregister(): # handle the keymap - wm = bpy.context.window_manager - for km in addon_keymaps: - wm.keyconfigs.addon.keymaps.remove(km) - # clear the list + for km, kmi in addon_keymaps: + km.keymap_items.remove(kmi) addon_keymaps.clear() @@ -568,18 +566,16 @@ Bringing it all together km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY') kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True) kmi.properties.total = 4 - addon_keymaps.append(km) + addon_keymaps.append((km, kmi)) def unregister(): bpy.utils.unregister_class(ObjectCursorArray) bpy.types.VIEW3D_MT_object.remove(menu_func) # handle the keymap - wm = bpy.context.window_manager - for km in addon_keymaps: - wm.keyconfigs.addon.keymaps.remove(km) - # clear the list - del addon_keymaps[:] + for km, kmi in addon_keymaps: + km.keymap_items.remove(kmi) + addon_keymaps.clear() if __name__ == "__main__": -- cgit v1.2.3