def extract(match: Match) -> Generator: path = yield match.group('path') lnum = yield match.group('lnum') lnum_i = yield parse_int(lnum) col = match.group('col') // parse_int error = yield match.group('error') yield Right((Path(path), lnum_i, col, error))
def substitute(files: Files, path: Path, lnum: int, col: Either[str, int], error: str, coco_path: Path) -> Generator: lines = yield files.lift(path).to_either('corrupt state') line = yield lines.lift(lnum - 1).to_either(f'invalid line number {lnum} for {path}') lnum_match = yield lnum_rex.search(line) coco_lnum = yield lnum_match.group('lnum') coco_lnum_i = yield parse_int(coco_lnum) col_map = col / (lambda a: Map(col=a)) | Map() yield Right(Map(lnum=coco_lnum_i, text=error, valid=1, maker_name='mypy') ** col_map)
def from_tmux( pane_id: str, pane_width: str, pane_height: str, pane_top: str, pane_pid: str, window_id: str, session_id: str, ) -> Do: id = yield parse_pane_id(pane_id) width = yield parse_int(pane_width) height = yield parse_int(pane_height) top = yield parse_int(pane_top) pid = yield parse_int(pane_pid) wid = yield parse_window_id(window_id) sid = yield parse_session_id(session_id) yield Right(PaneData(id, width, height, top, pid, wid, sid))
def from_tmux(window_id: str, window_width: str, window_height: str) -> Do: id = yield parse_window_id(window_id) w = yield parse_int(window_width) h = yield parse_int(window_height) yield Right(WindowData(id, w, h))
def parse_window_id(window_id: str) -> Do: match = yield window_id_re.match(window_id) id_s = yield match.group('id') yield parse_int(id_s)
def parse_bool(data: str) -> Do: as_int = yield parse_int(data) yield (Right(as_int == 1) if as_int in [0, 1] else Left(f'invalid number for boolean: {as_int}'))
def parse_pane_id(pane_id: str) -> Do: match = yield pane_id_re.match(pane_id) id_s = yield match.group('id') yield parse_int(id_s)
def parse_session_id(session_id: str) -> Do: match = yield session_id_re.match(session_id) id_s = yield match.group('id') yield parse_int(id_s)