コード例 #1
0
ファイル: __init__.py プロジェクト: zaqwes8811/matlab_ext
def generate_get(template, call_back):
    mib_name = 'TRANSMITTER-MIB'
    cash_file = call_back(template)

    import sys
    print '#@Autogenerated by ', sys.argv
    for record in cash_file:
        keys, oid, note = record
        method_name = 'get_'+to_name(oid)
        head = '\tdef '+method_name+'(self):\r\n'
        for key in keys:
            head += '\t\tvalue = self.access_map_["'+key+'"]\r\n'
        print head+'\t\treturn result'

    print '\tdef export_accessors(self):\r\n'+ \
        "\t\tMibObject = collections.namedtuple('MibObject', ['mibName', 'objectType', 'valueFunc', 'writeFunction'])\r\n"+ \
        "\t\taccess_mapper =  [ \\"
    for record in cash_file:
        key, oid, note = record
        method_name = 'get_'+to_name(oid)
        print "\t\t\tMibObject('"+mib_name+"', '"+oid+"', self."+method_name+", None),"
      
    print '\t\t\t]\r\n\t\treturn access_mapper'  
        
    print '#@Autogenerated by ', sys.argv
コード例 #2
0
ファイル: __init__.py プロジェクト: zaqwes8811/matlab_ext
def generate_get_set(mib_name, template, call_back):
    cash_file = call_back(template)

    import sys
    print '#@Autogenerated by ', sys.argv
    for oid in cash_file:
        keys, oid, note = oid
        
        get_method_name = 'get_'+to_name(oid)
        set_method_name = 'set_'+to_name(oid)
        
        #print '    #@Record: '+oid_name
        method = '    def '+get_method_name+'(self):\r\n        return self.access_map_["'+keys[0]+'"]'
        #print method
        method = '    def '+set_method_name+'(self):\r\n        pass\r\n'
        #print method, '\n'
        
        # Шаблон подключения к базе данных
        print "MibObject('"+mib_name+"', '"+oid+"', self."+get_method_name+", self."+set_method_name+"),"
        
    print '#@Autogenerated by ', sys.argv