Demo entry 6350570

py

   

Submitted by anonymous on Mar 13, 2017 at 09:02
Language: Python. Code size: 1.3 kB.

def Demo(is_web):
    ret = True
    rst_obj = ChkResultInfo()
    'Item1Test还有子项,所以rst尚未确定,必须等子项确定了才能确定'
    rst_obj.SetResult(module="Item1Test", new_msg=None, rst=None, level=1)
    'subItem1Test, 要输出提示信息, 使用SetResult,设置输出显示信息'
    msg = "[Info]: Hello SubItem2"
    rst_obj.SetResult(module="Itme1-SubItem1Test", new_msg=msg, level=2)
    '子项1---subItem1Test,使用SetResult, 增加一条要输出的提示信息'
    if type(1) == int:
        msg = "[Info]: It's a number"
        rst_obj.SetResult(module="Itme1-SubItem1Test", new_msg=msg, rst = True)
    else:
        ret = False
        msg = "[Error]: It's not a number"
        rst_obj.SetResult(module="Itme1-SubItem1Test", new_msg=msg, rst = False)

    '子项2---subItem2Test, 新增子项使用SetResult'
    if type(2) == str:
        msg = "[Error]: It's not a string"
        rst_obj.SetResult(module="Itme1-SubItem2Test", new_msg=msg, rst = True, level=2)
    else:
        ret = False
        msg = "[Error]: It's not a string"
        rst_obj.SetResult(module="Itme1-SubItem2Test", new_msg=msg, rst = False, level=2)
    '所有子项均确定后,重新设置父项结果,使用ResetResult'
    rst_obj.ResetResult(module="Item1Test", rst=ret, new_msg=None)
    '输出结果'
    if is_web:
        rst_obj.PrintWebMsg()
    else:
        rst_obj.print_Msg()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).