[Bf-extensions-cvs] [3a1b03b] master: API Navigator: Cleanup, UI fixes
lijenstina
noreply at git.blender.org
Thu Mar 30 11:47:09 CEST 2017
Commit: 3a1b03b5a615614c63ead5a484ae33ce4a92f065
Author: lijenstina
Date: Thu Mar 30 11:45:23 2017 +0200
Branches: master
https://developer.blender.org/rBA3a1b03b5a615614c63ead5a484ae33ce4a92f065
API Navigator: Cleanup, UI fixes
Bumped version to 1.0.3
Pep8 cleanup
imports as tuples
Removed an empty operator FakeButton
too much fuss for a tooltip
UI uses embossed buttons set to True
Moved the list size filter to the top
Moved the PropertyGroup out of register
===================================================================
M development_api_navigator.py
===================================================================
diff --git a/development_api_navigator.py b/development_api_navigator.py
index e7db1cf..7be8a73 100644
--- a/development_api_navigator.py
+++ b/development_api_navigator.py
@@ -2,7 +2,6 @@
#
# ***** BEGIN GPL LICENSE BLOCK *****
#
-#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
@@ -22,12 +21,12 @@
bl_info = {
"name": "API Navigator",
"author": "Dany Lebel (Axon_D)",
- "version": (1, 0, 2),
+ "version": (1, 0, 3),
"blender": (2, 57, 0),
"location": "Text Editor > Properties > API Navigator Panel",
"description": "Allows exploration of the python api via the user interface",
"warning": "",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Text_Editor/API_Navigator",
"category": "Development",
}
@@ -58,77 +57,73 @@ with the Escape key. (but a bug prevent the keymap to register correctly at star
"""
import bpy
+from bpy.types import (
+ Operator,
+ Panel,
+ PropertyGroup,
+ )
+from bpy.props import (
+ StringProperty,
+ IntProperty,
+ PointerProperty
+ )
from console.complete_import import get_root_modules
-############ Global Variables ############
-
-last_text = None # last text data block
-
-root_module = None # root module of the tree
-
-root_m_path = '' # root_module + path as a string
+# ########## Global Variables ##########
+last_text = None # last text data block
+root_module = None # root module of the tree
+root_m_path = '' # root_module + path as a string
current_module = None # the object itself in the tree structure
+tree_level = None # the list of objects from the current_module
-tree_level = None # the list of objects from the current_module
-
def init_tree_level():
global tree_level
- tree_level = [[],[],[],[],[],[],[], [], []]
-
-init_tree_level()
+ tree_level = [[], [], [], [], [], [], [], [], []]
-api_doc_ = '' # the documentation formated for the API Navigator
+init_tree_level()
+api_doc_ = '' # the documentation formated for the API Navigator
module_type = None # the type of current_module
-
return_report = '' # what current_module returns
+filter_mem = {} # remember last filters entered for each path
+too_long = False # is tree_level list too long to display in a panel?
-filter_mem = {} # remember last filters entered for each path
-
-too_long = False # is tree_level list too long to display in a panel?
-
-
-############ Functions ############
+# ########## Functions ############
def get_root_module(path):
- #print('get_root_module')
global root_module
if '.' in path:
root = path[:path.find('.')]
- else :
+ else:
root = path
- try :
+ try:
root_module = __import__(root)
- except :
+ except:
root_module = None
def evaluate(module):
- #print('evaluate')
global root_module, tree_level, root_m_path
- # path = bpy.context.window_manager.api_nav_props.path
- try :
+ try:
len_name = root_module.__name__.__len__()
root_m_path = 'root_module' + module[len_name:]
current_module = eval(root_m_path)
return current_module
- except :
+ except:
init_tree_level
return None
def get_tree_level():
- #print('get_tree_level')
path = bpy.context.window_manager.api_nav_props.path
def object_list():
- #print('object_list')
global current_module, root_m_path
itm, val, mod, typ, props, struct, met, att, bug = [], [], [], [], [], [], [], [], []
@@ -138,22 +133,19 @@ def get_tree_level():
current_type = str(module_type)
if current_type != "<class 'str'>":
if iterable == 'a':
- #if iterable == 'a':
- #current_type.__iter__()
itm = list(current_module.keys())
if not itm:
val = list(current_module)
- else :
+ else:
val = list(current_module)
for i in dir(current_module):
- try :
+ try:
t = str(type(eval(root_m_path + '.' + i)))
except (AttributeError, SyntaxError):
bug += [i]
continue
-
if t == "<class 'module'>":
mod += [i]
elif t[0:16] == "<class 'bpy_prop":
@@ -164,7 +156,7 @@ def get_tree_level():
met += [i]
elif t == "<class 'type'>":
typ += [i]
- else :
+ else:
att += [i]
return [itm, val, mod, typ, props, struct, met, att, bug]
@@ -176,8 +168,6 @@ def get_tree_level():
def parent(path):
"""Returns the parent path"""
- #print('parent')
-
parent = path
if parent[-1] == ']' and '[' in parent:
while parent[-1] != '[':
@@ -185,7 +175,7 @@ def parent(path):
elif '.' in parent:
while parent[-1] != '.':
parent = parent[:-1]
- else :
+ else:
return ''
parent = parent[:-1]
return parent
@@ -195,19 +185,18 @@ def update_filter():
"""Update the filter according to the current path"""
global filter_mem
- try :
+ try:
bpy.context.window_manager.api_nav_props.filter = filter_mem[bpy.context.window_manager.api_nav_props.path]
- except :
+ except:
bpy.context.window_manager.api_nav_props.filter = ''
def isiterable(mod):
-
- try :
+ try:
iter(mod)
- except :
+ except:
return False
- try :
+ try:
mod['']
return 'a'
except KeyError:
@@ -221,13 +210,13 @@ def fill_filter_mem():
filter = bpy.context.window_manager.api_nav_props.filter
if filter:
- filter_mem[bpy.context.window_manager.api_nav_props.old_path] = bpy.context.window_manager.api_nav_props.filter
- else :
+ filter_mem[bpy.context.window_manager.api_nav_props.old_path] = \
+ bpy.context.window_manager.api_nav_props.filter
+ else:
filter_mem.pop(bpy.context.window_manager.api_nav_props.old_path, None)
-###### API Navigator parent class #######
-
+# #### API Navigator parent class ######
class ApiNavigator():
"""Parent class for API Navigator"""
@@ -242,7 +231,7 @@ class ApiNavigator():
last_text = bpy.context.space_data.text.name
elif bpy.data.texts.__len__() < 2:
last_text = None
- else :
+ else:
last_text = None
bpy.context.window_manager.api_nav_props.pages = 0
get_root_module(bpy.context.window_manager.api_nav_props.path)
@@ -254,7 +243,7 @@ class ApiNavigator():
if tree_level.__len__() > 30:
global too_long
too_long = True
- else :
+ else:
too_long = False
ApiNavigator.generate_api_doc()
@@ -266,7 +255,7 @@ class ApiNavigator():
global current_module, api_doc_, return_report, module_type
path = bpy.context.window_manager.api_nav_props.path
- line = "-" * (path.__len__()+2)
+ line = "-" * (path.__len__() + 2)
header = """\n\n\n\t\t%s\n\t %s\n\
_____________________________________________\n\
\n\
@@ -300,11 +289,11 @@ _____________________________________________\n\
space_data = bpy.context.space_data
- try :
+ try:
doc_text = bpy.data.texts['api_doc_']
space_data.text = doc_text
doc_text.clear()
- except :
+ except:
bpy.data.texts.new(name='api_doc_')
doc_text = bpy.data.texts['api_doc_']
space_data.text = doc_text
@@ -313,8 +302,7 @@ _____________________________________________\n\
return {'FINISHED'}
-
-############ Operators ############
+# ######### Operators ###########
def api_update(context):
if bpy.context.window_manager.api_nav_props.path != bpy.context.window_manager.api_nav_props.old_path:
fill_filter_mem()
@@ -324,7 +312,7 @@ def api_update(context):
ApiNavigator.doc_text_datablock()
-class Update(ApiNavigator, bpy.types.Operator):
+class Update(ApiNavigator, Operator):
"""Update the tree structure"""
bl_idname = "api_navigator.update"
bl_label = "API Navigator Update"
@@ -334,8 +322,8 @@ class Update(ApiNavigator, bpy.types.Operator):
return {'FINISHED'}
-class BackToBpy(ApiNavigator, bpy.types.Operator):
- """go back to module bpy"""
+class BackToBpy(ApiNavigator, Operator):
+ """Go back to module bpy"""
bl_idname = "api_navigator.back_to_bpy"
bl_label = "Back to bpy"
@@ -343,7 +331,7 @@ class BackToBpy(ApiNavigator, bpy.types.Operator):
fill_filter_mem()
if not bpy.context.window_manager.api_nav_props.path:
bpy.context.window_manager.api_nav_props.old_path = bpy.context.window_manager.api_nav_props.path = 'bpy'
- else :
+ else:
bpy.context.window_manager.api_nav_props.old_path = bpy.context.window_manager.api_nav_props.path = 'bpy'
update_filter()
self.generate_global_values()
@@ -351,20 +339,27 @@ class BackToBpy(ApiNavigator, bpy.types.Operator):
return {'FINISHED'}
-class Down(ApiNavigator, bpy.types.Operator):
- """go to this Module"""
+class Down(ApiNavigator, Operator):
+ """Go to this Module"""
bl_idname = "api_navigator.down"
bl_label = "API Navigator Down"
- pointed_module = bpy.props.StringProperty(name='Current Module', default='')
+ pointed_module = StringProperty(
+ name="Current Module",
+ default=""
+ )
def execute(self, context):
fill_filter_mem()
if not bpy.context.window_manager.api_nav_props.path:
- bpy.context.win
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list