BuiltInFunctionSharedResources.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码
def Set_List_Shared_Variables(list_name, key, value, protected = False):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        global shared_variables, protected_variables
        if key == '' or key == None or value == '' or value == None or list_name == '' or list_name == None:  # if input is invalid
            return "failed"
        else: # Valid input
            if protected: protected_variables.append(key) # Add to list of protected variables
            else: # Check if user is trying to overwrite a protected variable
                if key in protected_variables: # If we find a match, exit with failure
                    CommonUtil.ExecLog(sModuleInfo, "Error: You tried to overwrite protected variable '%s'. Please choose a different variable name." % key, 3)
                    return 'failed'

            # Good to proceed
            if list_name in shared_variables:
                shared_variables[list_name][key] = value
                CommonUtil.ExecLog(sModuleInfo, "In List '%s' Variable value of '%s' is set as: %s" % (list_name, key, value), 0)
                return "passed"
            else:
                CommonUtil.ExecLog(sModuleInfo,
                        "List named %s does not exist on shared variables, so cant insert new field to list" % list_name,
                        3)
                return "failed"
    except:
        CommonUtil.Exception_Handler(sys.exc_info())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号