def run(self, qAndaDict=None, **kwds): content = kwds.get("content") ignore_target = kwds.get("ignore_target", []) self.transfKey = "key" not in ignore_target self.transfVal = "val" not in ignore_target self.ignoreKeys = kwds.get("ignore_keys", []) self.need_expand_variables = kwds.get("need_expand_variables", True) belong_to_project = kwds.get("belong_to_project", False) record_mode = kwds.get("record_mode", "record") self.qAndaDict = qAndaDict key = content["key"] if self.qAndaDict is not None: key = Str.renderText(key, **self.qAndaDict) key = key.lower() if record_mode == "erase": self.vEraseContent(key, belong_to_project) return elif record_mode == "toggle": self.vEraseContent(key, belong_to_project) elif record_mode == "record": pass else: sublime.error_message( "record_mode: {} is not allowed".format(record_mode)) self.vPreTransContent(key, content) content = Data.transfJsonObj(content, self.needTransf, self.transf) self.vPostTransContent(content) self.vRecordContent(key, content, belong_to_project)
def run(self, qAndaDict=None, **kwds): _async = kwds.pop("async", True) commands = kwds.pop("commands") run_mode = kwds.pop("run_mode", "capture_both") win_mode = kwds.pop("win_mode", "hide") run_opts = kwds.pop("run_opts", {}) dyn_report_mul = kwds.pop("dyn_report_mul", True) if qAndaDict: commands = [Str.renderText(cmd, **qAndaDict) for cmd in commands] commands = Setting.expandVariables(self.window, *commands) cwd, = Setting.expandVariables(self.window, run_opts.get("cwd", "${file_path}")) if cwd: run_opts["cwd"] = cwd workParams = dict(commands=commands, run_mode=run_mode, win_mode=win_mode, run_opts=run_opts, dyn_report_mul=dyn_report_mul ) print(workParams) if _async: view = self.window.active_view() self.asncCmdCount += 1 if run_mode != "run": view.set_status(ASYNC_STATUS_KEY, "***asnc command running***") self.doWorkAsnc(view, workParams, **kwds) else: self.doWork(**Data.mergeDicts(kwds, workParams))
def transf(self, obj, _): if self.qAndaDict is not None: obj = Str.renderText(obj, **self.qAndaDict) if self.need_expand_variables: obj, = Setting.expandVariables(self.window, obj) return obj
def run(self, qAndaDict=None, **kwds): _async = kwds.pop("async", True) self.code = kwds.pop("code") if qAndaDict: self.code = Str.renderText(self.code, **qAndaDict) if _async: view = self.window.active_view() self.asncCmdCount += 1 view.set_status(ASYNC_STATUS_KEY, "***asnc code running***") self.doWorkAsnc(view, **kwds) else: self.doWork(**kwds)