def mainIif( interactive=False, ): """ Doc String for mainIif """ iimRole='iif' iifParamsMandatory=['1', '2'] iifParamsOptional=[1,2] iifArgsLen=["1+,1,1-", "2"] ####+BEGINNOT: bx:dblock:global:file-insert :file "/libre/ByStar/InitialTemplates/software/plusOrg/dblock/inserts/iimFuncHead.py" try: iim.auxInvoke( iimRole=iimRole, iifParamsMandatory=iifParamsMandatory, iifParamsOptional=iifParamsOptional, iifArgsLen=iifArgsLen, ) except StopIteration: return G = iim.IimGlobalContext() G.curFuncNameSet(iim.FUNC_currentGet().__name__) ####+END: inMsg = msgIn.getMsgFromStdin() msgOut.envelopeInfoHeaders(inMsg) print(inMsg.as_string()) return
def g_invokesProc(): """Invoke the specified function. This is here and not in iim.g_invokesProc because of naming scopes. Can't -- eval(invoke + '()') -- from within iim library. """ G = iim.IimGlobalContext() iimRunArgs = G.iimRunArgsGet() g_iimPreIifs() for invoke in iimRunArgs.invokes: #func = iim.FUNC_strToFunc(invoke) try: eval(invoke + '(interactive=True)') #func(args) except Exception as e: iim.EH_critical_exception(e) iim.EH_problem_info("Invalid Action: {invoke}" .format(invoke=invoke)) raise g_iimPostIifs() return
def g_iimPreIifs(): G = iim.IimGlobalContext() iimFuncs=G.iimModuleFunctionsList() # func_auxInvokable does a setattr for func's auxInvokable attribute for func in iimFuncs: if iim.str_endsWith(func.name, "_auxInvokable"): eval(func.name + '()') iifsList=list() for func in iimFuncs: callable = iim.FUNC_strToFunc(func.name) try: if callable.auxInvokable: #print "{func} is YES auxInvokable".format(func=func.name) G.auxInvokationContextSet(iim.AuxInvokationContext.IimRole) eval(func.name + '()') auxResults = G.auxInvokationResults() if auxResults == "iif": iifsList.append(func.name) except AttributeError: pass #print "{func} is NOT auxInvokable".format(func=func.name) G.iifNamesSet(iifsList) #print(iifsList) for func in iimFuncs: callable = iim.FUNC_strToFunc(func.name) try: if callable.auxInvokable: #print "{func} is YES auxInvokable".format(func=func.name) G.auxInvokationContextSet(iim.AuxInvokationContext.DocString) eval(func.name + '()') #auxResults = G.auxInvokationResults() #if auxResults == "iif": #iifsList.append(func.name) except AttributeError: pass #print "{func} is NOT auxInvokable".format(func=func.name) iim.iimParamsToFileParamsUpdate( parRoot="./var/{myName}/iimIn/paramsFp".format(myName=G.iimMyName()), iimParams=G.iimParamDictGet(), )
def g_argsExtraSpecify(parser): """Module Specific Command Line Parameters. g_argsExtraSpecify is passed to G_main and is executed before argsSetup (can not be decorated) """ G = iim.IimGlobalContext() iimParams = iim.IIM_ParamDict() empna.targetParamListCommonArgs(parser) iim.argsparseBasedOnIimParams(parser, iimParams) # So that it can be processed later as well. G.iimParamDictSet(iimParams) return