| 551 | return bin_path |
| 552 | |
| 553 | def use2project(self, project_name: str): |
| 554 | if not project_name: |
| 555 | return |
| 556 | with open(self.project_to_pyenv_map_file, "r+") as f: |
| 557 | home = os.path.dirname(os.path.dirname(self.bin_path)) |
| 558 | for i in _SYS_BIN_PATH: |
| 559 | if self.bin_path.startswith(i): |
| 560 | home = i |
| 561 | break |
| 562 | data = f.read() |
| 563 | |
| 564 | lines = data.split("\n") |
| 565 | for i, line in enumerate(lines): |
| 566 | if line.startswith(project_name + ":"): |
| 567 | lines[i] = "{}:{}".format(project_name, home) |
| 568 | break |
| 569 | else: |
| 570 | lines.append("{}:{}".format(project_name, home)) |
| 571 | f.seek(0) |
| 572 | f.truncate() |
| 573 | f.write("\n".join(lines)) |
| 574 | |
| 575 | |
| 576 | class _EnvironmentDetector: |