示例#1
0
 def _showPorts(self, ports):
     if ports:
         table = TablePrinter('Port Name', 'Port Interface')
         for port in ports.itervalues():
             table.append(port['Port Name'], port['Port Interface'])
         table.write()
     else:
         print "None"
示例#2
0
    def api(self):
        print 'Allocation Properties ======'
        if not self._allocProps:
            print 'None'
            return

        table = TablePrinter('Property Name', '(Data Type)', 'Action')
        for prop in self._allocProps:
            table.append(prop.clean_name, '('+prop.type+')', prop.action)
            if prop.type in ('struct', 'structSeq'):
                if prop.type == 'structSeq':
                    structdef = prop.structDef
                else:
                    structdef = prop
                for member in structdef.members.itervalues():
                    table.append('  '+member.clean_name, member.type)
        table.write()
示例#3
0
    def api(self):
    
        kinds = []
        print "\nProperty\n--------"
        print "% -*s %s" % (17,"ID:",self.id)
        print "% -*s %s" % (17,"Type:",self.type)
        simpleOrSequence = False
        if self.type != "structSeq" and self.type != "struct":
            simpleOrSequence = True
            print "% -*s %s" % (17,"Default Value:", self.defValue)
            if self.mode != "writeonly":
                print "% -*s %s" % (17,"Value: ", self.queryValue())
            try:
                if self._enums != None:
                    print "% -*s %s" % (17,"Enumumerations:", self._enums)
            except:
                simpleOrSequence = True
        if self.type != "struct":
            print "% -*s %s" % (17,"Action:", self.action) 
        print "% -*s %s" % (17,"Mode: ", self.mode)

        if self.type == "struct":
            structTable = TablePrinter('Name','Data Type','Default Value', 'Current Value','Enumerations')
            structTable.limit_column(1,20)
            structTable.limit_column(2,15)
            structTable.limit_column(3,15)
            structTable.limit_column(4,40)
            for prop in self.compRef._prf.get_struct():
                if prop.id_ == self.id:
                    first = True
                    for simple in prop.get_simple():
                        defVal,value, type, kinds,enums = self._getStructsSimpleProps(simple,prop)
                        structTable.append(simple.get_id(),type,str(defVal),str(value),enums)
                        if first:
                            print "% -*s %s" % (17,"Kinds: ", ', '.join(kinds))
                            first = False
            structTable.write()
        elif self.type == "sequence":
            print "sequence: ",type(self)

        elif self.type == "structSeq":
            structNum = -1
            structTable = TablePrinter('Name','Data Type')
            structTable.limit_column(1,35)
            for prop in self.compRef._prf.get_structsequence():
                for kind in prop.get_configurationkind():
                    kinds.append(kind.get_kindtype())
                if prop.id_ == self.id and prop.get_struct() != None:
                    for simple in prop.get_struct().get_simple():
                        structTable.append(simple.id_, simple.get_type())
            print "% -*s %s" % (17,"Kinds: ", ', '.join(kinds))
            print "\nStruct\n======"
            structTable.write()

            simpleTable = TablePrinter('Index','Name','Value')
            simpleTable.limit_column(1,30)
            simpleTable.limit_column(2,35)
            for i in self.compRef._properties:
                if i.type == "structSeq" and self.mode != "writeonly":
                    for s in i:
                        structNum +=1
                        for key in s.keys():
                            simpleTable.append(str(structNum),key,str(s[key]))
            if self.mode != "writeonly":
                print "\nSimple Properties\n================="
                simpleTable.write()

        elif simpleOrSequence:
            for prop in self.compRef._prf.get_simple() + self.compRef._prf.get_simplesequence():
                if prop.id_ == self.id:
                    for kind in prop.get_kind():
                        kinds.append(kind.get_kindtype())
            print "% -*s %s" % (17,"Kinds: ", ', '.join(kinds))
示例#4
0
    def api(self, externalPropInfo=None):
        properties = [p for p in self._properties if 'configure' in p.kinds or 'execparam' in p.kinds]
        if not properties:
            return

        table = TablePrinter('Property Name', '(Data Type)', '[Default Value]', 'Current Value')

        # Limit the amount of space between columns of data for display
        table.limit_column(1, 32)
        table.limit_column(2, 24)

        if externalPropInfo:
            # For external props, extract their information
            extId, propId = externalPropInfo
            table.enable_header(False)
        else:
            print "Properties =============="
        for prop in properties:
            if externalPropInfo:
                # Searching for a particular external property
                if prop.clean_name != propId:
                    continue
                name = extId
            else:
                name = prop.clean_name
            writeOnly = False
            if prop.mode != "writeonly":
                currentValue = prop.queryValue()
            else:
                writeOnly = True
                currentValue = "N/A"

            scaType = _formatType(prop.type)
            if prop.type == 'structSeq':
                table.append(name, '('+scaType+')')
                if writeOnly:
                    currentValue = "N"
                for item_count, item in enumerate(currentValue):
                    for member in prop.valueType:
                        _id = str(member[0])
                        scaType = str(member[1])
                        defVal = str(member[2])
                        if not writeOnly:
                            currVal = str(item[member[0]])
                        else:
                            currVal = "N/A"
                        name = ' [%d] %s' % (item_count, _id)
                        scaType = _formatType(scaType)
                        table.append(name, '('+scaType+')', defVal, currVal)
            elif prop.type == 'struct':
                table.append(name, '('+scaType+')')
                for member in prop.members.itervalues():
                    name = ' ' + member.clean_name
                    scaType = _formatType(member.type)
                    if not writeOnly:
                        _currentValue = _formatSimple(member, currentValue[member.id],member.id)
                    else: 
                        _currentValue = "N/A"
                    table.append(' '+name, '('+scaType+')', str(member.defValue), _currentValue)
            else:
                currentValue = _formatSimple(prop, currentValue,prop.id)
                table.append(name, '('+scaType+')', str(prop.defValue), currentValue)

        table.write()