[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37362] trunk/blender/release/scripts/ modules/console/complete_namespace.py: added a check to console auto-compleation for pythons struct_seq type, so bpy.app and sys. float_info autocompleate their attributes rather then bring treated as a typle .

Campbell Barton ideasman42 at gmail.com
Fri Jun 10 11:44:27 CEST 2011


Revision: 37362
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37362
Author:   campbellbarton
Date:     2011-06-10 09:44:27 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
added a check to console auto-compleation for pythons struct_seq type, so bpy.app and sys.float_info autocompleate their attributes rather then bring treated as a typle.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/console/complete_namespace.py

Modified: trunk/blender/release/scripts/modules/console/complete_namespace.py
===================================================================
--- trunk/blender/release/scripts/modules/console/complete_namespace.py	2011-06-10 09:33:23 UTC (rev 37361)
+++ trunk/blender/release/scripts/modules/console/complete_namespace.py	2011-06-10 09:44:27 UTC (rev 37362)
@@ -37,6 +37,11 @@
     return hasattr(obj, 'keys') and hasattr(getattr(obj, 'keys'), '__call__')
 
 
+def is_struct_seq(obj):
+    """Returns whether obj is a structured sequence subclass: sys.float_info"""
+    return isinstance(obj, tuple) and hasattr(obj, 'n_fields')
+
+
 def complete_names(word, namespace):
     """Complete variable names or attributes
 
@@ -174,7 +179,7 @@
         if type(obj) in (bool, float, int, str):
             return []
         # an extra char '[', '(' or '.' will be added
-        if hasattr(obj, '__getitem__'):
+        if hasattr(obj, '__getitem__') and not is_struct_seq(obj):
             # list or dictionary
             matches = complete_indices(word, namespace, obj)
         elif hasattr(obj, '__call__'):




More information about the Bf-blender-cvs mailing list