def virtualenv_interpreter(venv: str, executable: str) -> Do: path_s = yield IO.from_either(env.get('PATH')) path = Lists.split(path_s, ':') clean_path = path.filter_not(lambda a: a.startswith(venv)) candidate = yield IO.delay(shutil.which, executable, path=clean_path.mk_string(':')) return Path(candidate)
def json_type(tpe: Type) -> Json: mod = '__builtins__' if tpe.__module__ == 'builtins' else tpe.__module__ names = Lists.split(qualname(tpe), '.').map(JsonScalar) return JsonObject(Map(module=JsonScalar(mod), names=JsonArray(names)))
def tmux_attr_map(attrs: List[str], output: str) -> Map[str, str]: tokens = Lists.split(output, ' ') return Map(attrs.zip(tokens))