def parseAction(self,config): s=[] for elem in config["content"]: if type(elem) is str: s.append(elem) return { "command":config["command"], "number":prepareVars("".join(s).strip()), }
def parseAction(self, config): cmd = config.get("command") if cmd in EXEC_CMD: return {"expr": makeTree("".join(config["content"]).strip()), "command": "exec"} s = [] for elem in config["content"]: if type(elem) is tuple: html = config["view"].output.get("format", "") == "html5" s.append(tree2xml(elem, not html, html=html)) elif type(elem) is str: s.append(elem) return {"string": prepareVars("".join(s).strip()), "output": config.get("output", None)}
def parseAction(self, action): """ Gets tuple representation of action XML element and returns dict-based configuration """ attrs = action[1] ns, cmd = NS2Tuple(attrs.get(COMMAND, "default")) params = {} if ns: for attr in attrs: if attr.startswith(ns + ":") and not attr == ns + cmd: params[attr.rsplit(":", 1)[1]] = prepareVars(action[1][attr]) ret = {"command": cmd, "params": params, "content": action[2], "view": self} if action[0] == NODE: ret["output"] = True return ret
def parseAction(self,conf): try: conf["params"]["From"] except KeyError: raise Error("FromAdressNotSpecified", "'From' should be specified") try: conf["params"]["To"] except KeyError: raise Error("ToAdressNotSpecified", "'To' should be specified") try: conf["params"]["Subject"] except KeyError: raise Error("SubjectNotSpecified", "'Subject' should be specified") params=conf["params"] for i in params: if params[i]: params[i]=prepareVars(params[i]) try: conf['content']=prepareVars("".join(conf['content'])) except: raise Error("StringExpected", "Please use CDATA mail content.") return conf
def parseAction(self,conf): query="" for node in conf["content"]: if type(node) is str: query=str(" ".join(node.split())) params=conf["params"] return { "query":prepareVars(query.strip()), "server":params.get("server", "default"), "return":params.get("return"), "command":conf["command"], #TODO change it to re.strip "cdata":map(str.strip,params.get("cdata","").split(",")) }
def parseAction(self, conf): if conf["command"] not in ("list", "create", "update", "append", "delete", "copy", "move", "exists", "get"): raise Error("Command '%s' do not exist!", config["command"]) ret={ "command":conf["command"] } if conf["content"]: s=[] for elem in conf["content"]: if type(elem) is tuple: s.append(tree2xml(elem)) elif type(elem) is str: s.append(elem) ret["content"]=prepareVars("\n".join(s)) ret["params"]=conf["params"] return ret