예제 #1
0
파일: gendoc.py 프로젝트: Zhanyin/taomee
def print_all_cmd_def(db):
	#打印DB的头部
	cmdlist=db["cmdlist"];
	keylist=cmdlist.keys();
	keylist.sort(gendoc_core.cmd_sort_cmp);

	id=0
	for k in keylist:
		cmditem=cmdlist[k]
		cmdname=cmditem["cmdname"];
		cmdid=cmditem["cmdid"];
		comment=gendoc_core.get_cmd_info(k)[2]
		need_update_flag=cmditem["need_update"]

		print "<table id=\"mytable_1\" cellspacing=\"0\" >";
		print "<tr><th width=50 class=\"title_def\">%d</th><th class=\"title_def\"><a name=%s_1 href=#%s_2 >%s</a> <a href='JavaScript:;' onclick=\"div_show('%s_php_code');\">php协议代码</a><br />%s</th><th class=\"title_def\" width=100 >%s<br />%s</th></tr>"%(
				id,cmdname,cmdname, cmdname,cmdname, comment, cmdid,need_update_flag )
		print "</table>"		

		php_code= gendoc_core.get_php_code(cmditem);
		print "<div id='%s_php_code' style='display:none;' align=center ><table><td class=alt> <pre>%s</pre></td></table></div>"%(cmdname,php_code)	
		in_stru=cmditem["in_stru"];
		#打印请求
		#print header
		print "<table id=\"mytable\" cellspacing=\"0\" >";
		print	"<caption >请求包:</caption>";
		print "<tr><th>字段</th><th>类型</th><th>说明</th></tr>"
	#	print in_stru;	
		len_in=len(in_stru);
		if (len_in==1 ):
			show_struct(in_stru[0]);
		elif (len_in==2 ):
			show_struct(in_stru[0],"");
			in_1=in_stru[1];
			print("<tr><td>%s</td><td>无</td><td>%s</td></tr>"%( in_1["struct_name"],
									gendoc_core.fd.getDesc(in_1["struct_name"] )))
			show_struct(in_1 ,">>>>&nbsp;" )
		elif (len_in>2):
			show_struct(in_stru[0],"");
			for i in range (1,len_in):
				in_item=in_stru[i];
				print("<tr><td>%s</td><td>无</td><td>%s</td></tr>"%(in_item["struct_name"],
									gendoc_core.fd.getDesc(in_item["struct_name"] )))

				show_struct(in_item,">>>>&nbsp;" )
		print "</table>";

		#打印返回包
		#print header
		print "<table id=\"mytable\" cellspacing=\"0\" >";
		print	"<caption >返回包:</caption>";
		print "<tr><th>字段</th><th>类型</th><th>说明</th></tr>"

		out_stru=cmditem["out_stru"];
	#	print out_stru;
		len_out=len(out_stru);
		if (len_out==1 ):
			show_struct(out_stru[0]);
		elif (len_out==2 ):
			show_struct(out_stru[0],"");
			out_1=out_stru[1];
			print("<tr><td>%s</td><td>无</td><td>%s</td></tr>"%( out_1["struct_name"],
									gendoc_core.fd.getDesc(out_1["struct_name"] )))
			show_struct(out_1 ,">>>>&nbsp;" )
		elif (len_out>2):
			show_struct(out_stru[0],"");
			for i in range (1,len_out):
				out_item=out_stru[i];
				print("<tr><td>%s</td><td>无</td><td>%s</td></tr>"%(out_item["struct_name"],
									gendoc_core.fd.getDesc(out_item["struct_name"] )))

				show_struct(out_item,">>>>&nbsp;" )
		print "</table>";

		#错误码
		print "<table id=\"mytable\" cellspacing=\"0\" >";
		print "<caption >错误码:</caption>";
		print "<tr><th>名字</th><th>数值</th><th>说明</th></tr>"
		err_list= cmditem["errlist"];
		for k in err_list .keys():
			err=err_list[k]
			v = gendoc_core .err_conf[err];
			print ( "<tr ><td >%s</td><td>%s</td><td>%s</td></tr>"%( err,v[0], v[1] ))
		print "</table>"		
		print "<br />"		

		id=id+1;
예제 #2
0
파일: gendoc.py 프로젝트: zhsfei/taomee
def print_all_cmd_def(db):
    #打印DB的头部
    cmdlist = db["cmdlist"]
    keylist = cmdlist.keys()
    keylist.sort(gendoc_core.cmd_sort_cmp)

    id = 0
    for k in keylist:
        cmditem = cmdlist[k]
        cmdname = cmditem["cmdname"]
        cmdid = cmditem["cmdid"]
        comment = gendoc_core.get_cmd_info(k)[2]
        need_update_flag = cmditem["need_update"]

        print "<table id=\"mytable_1\" cellspacing=\"0\" >"
        print "<tr><th width=50 class=\"title_def\">%d</th><th class=\"title_def\"><a name=%s_1 href=#%s_2 >%s</a> <a href='JavaScript:;' onclick=\"div_show('%s_php_code');\">php协议代码</a><br />%s</th><th class=\"title_def\" width=100 >%s<br />%s</th></tr>" % (
            id, cmdname, cmdname, cmdname, cmdname, comment, cmdid,
            need_update_flag)
        print "</table>"

        php_code = gendoc_core.get_php_code(cmditem)
        print "<div id='%s_php_code' style='display:none;' align=center ><table><td class=alt> <pre>%s</pre></td></table></div>" % (
            cmdname, php_code)
        in_stru = cmditem["in_stru"]
        #打印请求
        #print header
        print "<table id=\"mytable\" cellspacing=\"0\" >"
        print "<caption >请求包:</caption>"
        print "<tr><th>字段</th><th>类型</th><th>说明</th></tr>"
        #	print in_stru;
        len_in = len(in_stru)
        if (len_in == 1):
            show_struct(in_stru[0])
        elif (len_in == 2):
            show_struct(in_stru[0], "")
            in_1 = in_stru[1]
            print("<tr><td>%s</td><td>无</td><td>%s</td></tr>" %
                  (in_1["struct_name"],
                   gendoc_core.fd.getDesc(in_1["struct_name"])))
            show_struct(in_1, ">>>>&nbsp;")
        elif (len_in > 2):
            show_struct(in_stru[0], "")
            for i in range(1, len_in):
                in_item = in_stru[i]
                print("<tr><td>%s</td><td>无</td><td>%s</td></tr>" %
                      (in_item["struct_name"],
                       gendoc_core.fd.getDesc(in_item["struct_name"])))

                show_struct(in_item, ">>>>&nbsp;")
        print "</table>"

        #打印返回包
        #print header
        print "<table id=\"mytable\" cellspacing=\"0\" >"
        print "<caption >返回包:</caption>"
        print "<tr><th>字段</th><th>类型</th><th>说明</th></tr>"

        out_stru = cmditem["out_stru"]
        #	print out_stru;
        len_out = len(out_stru)
        if (len_out == 1):
            show_struct(out_stru[0])
        elif (len_out == 2):
            show_struct(out_stru[0], "")
            out_1 = out_stru[1]
            print("<tr><td>%s</td><td>无</td><td>%s</td></tr>" %
                  (out_1["struct_name"],
                   gendoc_core.fd.getDesc(out_1["struct_name"])))
            show_struct(out_1, ">>>>&nbsp;")
        elif (len_out > 2):
            show_struct(out_stru[0], "")
            for i in range(1, len_out):
                out_item = out_stru[i]
                print("<tr><td>%s</td><td>无</td><td>%s</td></tr>" %
                      (out_item["struct_name"],
                       gendoc_core.fd.getDesc(out_item["struct_name"])))

                show_struct(out_item, ">>>>&nbsp;")
        print "</table>"

        #错误码
        print "<table id=\"mytable\" cellspacing=\"0\" >"
        print "<caption >错误码:</caption>"
        print "<tr><th>名字</th><th>数值</th><th>说明</th></tr>"
        err_list = cmditem["errlist"]
        for k in err_list.keys():
            err = err_list[k]
            v = gendoc_core.err_conf[err]
            print("<tr ><td >%s</td><td>%s</td><td>%s</td></tr>" %
                  (err, v[0], v[1]))
        print "</table>"
        print "<br />"

        id = id + 1
예제 #3
0
def print_all_cmd_def(db,cmdid):
	#打印DB的头部
	cmdlist=db["cmdlist"];

	if (not cmdlist.has_key(cmdid) ):
		return ;

	cmditem=cmdlist[cmdid]
	cmdname=cmditem["cmdname"];
	cmdid_str=cmditem["cmdid"];
	comment=gendoc_core.command_conf[cmdid][2]
	need_update_flag=cmditem["need_update"]

	print "\033[1m\033[32m==============\033[0m 命令ID: \033[31m%s\033[0m  说明: \033[33m%s\033[0m  "%( cmdid_str,cmdname )

	in_stru=cmditem["in_stru"];

	print "\033[1m\033[31m请求包=========================================\033[0m"
	#打印请求
	#print in_stru;	
	len_in=len(in_stru);
	if (len_in==1 ):
		show_struct(in_stru[0],FS);
	elif (len_in==2 ):
		show_struct(in_stru[0],FS);
		in_1=in_stru[1];
		print(FS+"item_1")
		show_struct(in_1 ,FS+FS )
	elif (len_in>2):
		show_struct(in_stru[0],"");
		for i in range (1,len_in):
			in_item=in_stru[i];
			print( FS+"item_%d"%(i))
			show_struct(in_item,FS+FS )

	#打印返回包
	print "\033[1m\033[31m返回包========================================\033[0m"

	#print out_stru;	
	out_stru=cmditem["out_stru"];
	len_out=len(out_stru);
	if (len_out==1 ):
		show_struct(out_stru[0],FS);
	elif (len_out==2 ):
		show_struct(out_stru[0],FS);
		print(FS+"item_1")
		out_1=out_stru[1];
		show_struct(out_1 ,FS+FS )
	elif (len_out>2):
		show_struct(out_stru[0],"");
		for i in range (1,len_out):
			out_item=out_stru[i];
			print(FS+"item_%d"%(i))
			show_struct(out_item,FS+FS )

	#错误码
	print "\033[1m\033[31m错误码========================================\033[0m"
	err_list= cmditem["errlist"];
	for k in err_list .keys():
		err=err_list[k]
		v = gendoc_core .err_conf[err];
		print ( "%s%s%s%s%s\033[1m\033[34m#%s\033[0m "%( FS,v[0], FS,err,FS,v[1]  ))

	print gendoc_core.get_php_code(cmditem);

	print "\033[1m\033[32m==============\033[0m 命令ID: \033[31m%s\033[0m  说明: \033[33m%s\033[0m  "%( cmdid,cmdname )
예제 #4
0
파일: gendoc_txt.py 프로젝트: zhsfei/taomee
def print_all_cmd_def(db, cmdid):
    #打印DB的头部
    cmdlist = db["cmdlist"]

    if (not cmdlist.has_key(cmdid)):
        return

    cmditem = cmdlist[cmdid]
    cmdname = cmditem["cmdname"]
    cmdid_str = cmditem["cmdid"]
    comment = gendoc_core.command_conf[cmdid][2]
    need_update_flag = cmditem["need_update"]

    print "\033[1m\033[32m==============\033[0m 命令ID: \033[31m%s\033[0m  说明: \033[33m%s\033[0m  " % (
        cmdid_str, cmdname)

    in_stru = cmditem["in_stru"]

    print "\033[1m\033[31m请求包=========================================\033[0m"
    #打印请求
    #print in_stru;
    len_in = len(in_stru)
    if (len_in == 1):
        show_struct(in_stru[0], FS)
    elif (len_in == 2):
        show_struct(in_stru[0], FS)
        in_1 = in_stru[1]
        print(FS + "item_1")
        show_struct(in_1, FS + FS)
    elif (len_in > 2):
        show_struct(in_stru[0], "")
        for i in range(1, len_in):
            in_item = in_stru[i]
            print(FS + "item_%d" % (i))
            show_struct(in_item, FS + FS)

    #打印返回包
    print "\033[1m\033[31m返回包========================================\033[0m"

    #print out_stru;
    out_stru = cmditem["out_stru"]
    len_out = len(out_stru)
    if (len_out == 1):
        show_struct(out_stru[0], FS)
    elif (len_out == 2):
        show_struct(out_stru[0], FS)
        print(FS + "item_1")
        out_1 = out_stru[1]
        show_struct(out_1, FS + FS)
    elif (len_out > 2):
        show_struct(out_stru[0], "")
        for i in range(1, len_out):
            out_item = out_stru[i]
            print(FS + "item_%d" % (i))
            show_struct(out_item, FS + FS)

    #错误码
    print "\033[1m\033[31m错误码========================================\033[0m"
    err_list = cmditem["errlist"]
    for k in err_list.keys():
        err = err_list[k]
        v = gendoc_core.err_conf[err]
        print("%s%s%s%s%s\033[1m\033[34m#%s\033[0m " %
              (FS, v[0], FS, err, FS, v[1]))

    print gendoc_core.get_php_code(cmditem)

    print "\033[1m\033[32m==============\033[0m 命令ID: \033[31m%s\033[0m  说明: \033[33m%s\033[0m  " % (
        cmdid, cmdname)