MCPcopy
hub / github.com/pallets/click / edit_files

Method edit_files

src/click/_termui_impl.py:686–714  ·  view source on GitHub ↗

Open files in the user's editor.

(self, filenames: cabc.Iterable[str])

Source from the content-addressed store, hash-verified

684 return "vi"
685
686 def edit_files(self, filenames: cabc.Iterable[str]) -> None:
687 """Open files in the user's editor."""
688 import shlex
689 import subprocess
690
691 editor = self.get_editor()
692 environ: dict[str, str] | None = None
693
694 if self.env:
695 environ = os.environ.copy()
696 environ.update(self.env)
697
698 try:
699 # Split in POSIX mode (the default) for the same reasons as
700 # in pager(): strips quotes from tokens and preserves quoted
701 # Windows paths.
702 c = subprocess.Popen(
703 args=shlex.split(editor) + list(filenames),
704 env=environ,
705 )
706 exit_code = c.wait()
707 if exit_code != 0:
708 raise ClickException(
709 _("{editor}: Editing failed").format(editor=editor)
710 )
711 except OSError as e:
712 raise ClickException(
713 _("{editor}: Editing failed: {e}").format(editor=editor, e=e)
714 ) from e
715
716 @t.overload
717 def edit(self, text: bytes | bytearray) -> bytes | None: ...

Callers 8

editMethod · 0.95
editFunction · 0.95

Calls 3

get_editorMethod · 0.95
ClickExceptionClass · 0.85
updateMethod · 0.80