コード例 #1
0
 def _checkAttributeNames(self, item):
     result = introspect.getAttributeNames(item)
     attributes = [attribute for attribute in self.values \
                   if hasattr(item, attribute)]
     for attribute in attributes:
         self.assert_(attribute in result, 
                      ':item: %r :attribute: %r' % (item, attribute))
コード例 #2
0
 def _checkAttributeNames(self, item):
     result = introspect.getAttributeNames(item)
     attributes = [attribute for attribute in self.values \
                   if hasattr(item, attribute)]
     for attribute in attributes:
         self.assert_(attribute in result,
                      ':item: %r :attribute: %r' % (item, attribute))
コード例 #3
0
 def test_getAttributeNames_NoDouble(self):
     for item in self.items:
         result = introspect.getAttributeNames(item, includeDouble=0)
         attributes = [attribute for attribute in result \
                       if attribute[:2] != '__']
         self.assertEqual(result, attributes, 
                          ':item: %r' % (item,))
コード例 #4
0
 def test_getAttributeNames_NoDouble(self):
     for item in self.items:
         result = introspect.getAttributeNames(item, includeDouble=0)
         attributes = [attribute for attribute in result \
                       if attribute[:2] != '__']
         self.assertEqual(result, attributes, 
                          ':item: %r' % (item,))
コード例 #5
0
ファイル: homport.py プロジェクト: LouisDunlevy/homport
def getAutoCompleteList(command = '', locals = None, includeMagic = 1,
                        includeSingle = 1, includeDouble = 1):
    """
Return list of auto-completion options for command.
The list of options will be based on the locals namespace.
    """
    attributes = []
    # Get the proper chunk of code from the command.
    root = introspect.getRoot(command, terminator = '.')
    try:
        if locals is not None:
            object = eval(root, locals)
        else:
            object = eval(root)
    except:
        pass
    else:
        attributes = introspect.getAttributeNames(object, includeMagic,
                                                  includeSingle, includeDouble)
        def createlist(obj):
            return [s.name() for s in obj if s.name() not in attributes]

        if hasattr(object, "children"):
            attributes.extend(createlist(object.children()))

        if hasattr(object, "parms"):
            attributes.extend(createlist(object.parms()))

        if hasattr(object, "parmTuples"):
            attributes.extend(createlist(object.parmTuples()))

    return attributes
コード例 #6
0
ファイル: filling.py プロジェクト: LLNL/WVL
 def objGetChildren(self, obj):
     """Return dictionary with attributes or contents of object."""
     busy = wx.BusyCursor()
     otype = type(obj)
     if otype is types.DictType \
     or str(otype)[17:23] == 'BTrees' and hasattr(obj, 'keys'):
         return obj
     d = {}
     if otype is types.ListType or otype is types.TupleType:
         for n in range(len(obj)):
             key = '[' + str(n) + ']'
             d[key] = obj[n]
     if otype not in COMMONTYPES:
         for key in introspect.getAttributeNames(obj):
             # Believe it or not, some attributes can disappear,
             # such as the exc_traceback attribute of the sys
             # module. So this is nested in a try block.
             try:
                 if obj is wx.NullPen: #seb CRASH CHECK
                     if key == 'DashCount':
                         continue            # wxGTK  64bit Segmentation fault
                 d[key] = getattr(obj, key)
             except:
                 pass
     return d
コード例 #7
0
 def objGetChildren(self, obj):
     """Return dictionary with attributes or contents of object."""
     busy = wx.BusyCursor()
     otype = type(obj)
     if otype is types.DictType or str(otype)[17:23] == "BTrees" and hasattr(obj, "keys"):
         return obj
     d = {}
     if otype is types.ListType or otype is types.TupleType:
         for n in range(len(obj)):
             key = "[" + str(n) + "]"
             d[key] = obj[n]
     if otype not in COMMONTYPES:
         for key in introspect.getAttributeNames(obj):
             # Believe it or not, some attributes can disappear,
             # such as the exc_traceback attribute of the sys
             # module. So this is nested in a try block.
             try:
                 d[key] = getattr(obj, key)
             except:
                 pass
     return d
コード例 #8
0
 def objGetChildren(self, obj):
     """Return dictionary with attributes or contents of object."""
     busy = wx.BusyCursor()
     otype = type(obj)
     if otype is types.DictType \
     or str(otype)[17:23] == 'BTrees' and hasattr(obj, 'keys'):
         return obj
     d = {}
     if otype is types.ListType or otype is types.TupleType:
         for n in range(len(obj)):
             key = '[' + str(n) + ']'
             d[key] = obj[n]
     if otype not in COMMONTYPES:
         for key in introspect.getAttributeNames(obj):
             # Believe it or not, some attributes can disappear,
             # such as the exc_traceback attribute of the sys
             # module. So this is nested in a try block.
             try:
                 d[key] = getattr(obj, key)
             except:
                 pass
     return d
コード例 #9
0
ファイル: filling.py プロジェクト: chemscobra/sim42
 def getChildren(self, o):
     """Return a dictionary with the attributes or contents of object."""
     busy = wxBusyCursor()
     otype = type(o)
     if (otype is types.DictType) \
     or str(otype)[17:23] == 'BTrees' and hasattr(o, 'keys'):
         return o
     d = {}
     if otype is types.ListType:
         for n in range(len(o)):
             key = '[' + str(n) + ']'
             d[key] = o[n]
     if otype not in COMMONTYPES:
         for key in introspect.getAttributeNames(o):
             # Believe it or not, some attributes can disappear, such as
             # the exc_traceback attribute of the sys module. So this is
             # nested in a try block.
             try:
                 d[key] = getattr(o, key)
             except:
                 pass
     return d