MCPcopy Create free account
hub / github.com/caverav/flutterdec / entrypoint

Function entrypoint

adapters/python/adapter_template.py:708–780  ·  view source on GitHub ↗
(default_snapshot_hash: str = "unknown", default_version: str = "unknown")

Source from the content-addressed store, hash-verified

706 return libraries, classes, functions
707
708
709def _runner_mode(cmd: List[str]) -> str:
710 if not cmd:
711 return ""
712 exe = os.path.basename(cmd[0]).lower()
713 if exe.endswith("blutter.py"):
714 return "blutter_py"
715 if exe == "blutter":
716 return "blutter_bin"
717 return "custom"
718
719
720def _resolve_blutter_runner() -> Optional[List[str]]:
721 env_cmd = os.getenv("FLUTTERDEC_BLUTTER_CMD", "").strip()
722 if env_cmd:
723 return shlex.split(env_cmd)
724
725 env_py = os.getenv("FLUTTERDEC_BLUTTER_PY", "").strip()
726 if env_py:
727 py_exec = os.getenv("PYTHON", sys.executable or "python3")
728 return [py_exec, env_py]
729
730 found_py = shutil.which("blutter.py")
731 if found_py:
732 return [found_py]
733
734 found_bin = shutil.which("blutter")
735 if found_bin:
736 return [found_bin]
737
738 return None
739
740
741def _run_blutter_dump(input_path: Optional[str], libapp_path: Optional[str]) -> Path:
742 runner = _resolve_blutter_runner()
743 if not runner:
744 raise BackendUnavailable(
745 "blutter runner not found. set FLUTTERDEC_BLUTTER_CMD or FLUTTERDEC_BLUTTER_PY, or install blutter.py"
746 )
747
748 out_dir = Path(tempfile.mkdtemp(prefix="flutterdec-blutter-"))
749 mode = _runner_mode(runner)
750
751 if mode == "blutter_py":
752 if not input_path:
753 raise BackendFailed("blutter.py backend needs --input-path")
754 cmd = runner + [input_path, str(out_dir), "--no-analysis"]
755 elif mode == "blutter_bin":
756 if not libapp_path:
757 raise BackendFailed("blutter binary backend needs --libapp-path")
758 cmd = runner + ["-i", libapp_path, "-o", str(out_dir)]
759 else:
760 if not input_path:
761 raise BackendFailed("custom blutter backend needs --input-path")
762 cmd = runner + [input_path, str(out_dir)]
763
764 # The lock has to live beside the cache it protects. The adapter host gives
765 # every invocation a private HOME, so a lock under it would be private too

Callers 1

Calls 8

_read_bytesFunction · 0.85
_normalize_backendFunction · 0.85
_build_blutter_modelFunction · 0.85
_extract_stringsFunction · 0.85
_detect_snapshot_hashFunction · 0.85
_collect_librariesFunction · 0.85
_recover_functionsFunction · 0.85
_pool_entriesFunction · 0.85

Tested by

no test coverage detected