def notification_on_error(): try: yield except Exception as ex: notify(ex) log(traceback.format_exc()) exit(1)
def get_path_and_line(path_text, extra_text=""): for rule in parsers.RULES: log(rule.__class__.__name__) try: return rule.parse(path_text, extra_text) except parsers.ParseError as exc: log(exc) continue raise parsers.ParseError("No matching rule")
def visit_file(self, path, line): cmd = [ self.executable, "--no-wait", "--eval", '(find-file "%s")' % path, "--eval", "(goto-line %d)" % line, "--eval", "(select-frame-set-input-focus (selected-frame))", "--eval", "(when (functionp 'pulse-momentary-highlight-one-line) (let ((pulse-delay 0.05)) (pulse-momentary-highlight-one-line (point) 'highlight)))", ] log(" ".join(cmd)) subprocess.check_call(cmd)
def main(): log("") with notification_on_error(): if settings.sublime: Editor = editors.Sublime(settings.sublime) elif settings.emacsclient: Editor = editors.Emacs(settings.emacsclient) elif settings.vscode: Editor = editors.VSCode(settings.vscode) elif settings.pycharm: Editor = editors.PyCharm(settings.pycharm) else: raise Exception("No editor specified in settings.py") log("sys.argv: %s" % sys.argv) path_text, extra_text = sys.argv[1:] if hasattr(settings, "rewrite_path"): path_text = settings.rewrite_path(path_text) path, line = get_path_and_line(path_text, extra_text) log("Got path and line: %s %d" % (path, line)) Editor.visit_file(path, line)
def visit_file(self, path, line): cmd = [self.executable, "%s:%s" % (path, line)] log(" ".join(cmd)) subprocess.check_call(cmd)
def visit_file(self, path, line): cmd = [self.executable, "--line", str(line), path] log(" ".join(cmd)) subprocess.check_call([s.encode("utf-8") for s in cmd])