class_docstr: Manages a single kernel in a subprocess on this host.
  
  This version starts kernels with Popen.
docstr: Replace templated args (e.g. {connection_file})
docstr_tok: ["Replace","templated","args","(","e.g",".","{","connection_file","}",")"]
code: def format_kernel_cmd(
      self, extra_arguments: t.Optional[t.List[str]] = None
  ) -> t.List[str]:
      """Replace templated args (e.g. {connection_file})"""
      extra_arguments = extra_arguments or []
      assert self.kernel_spec is not None
      cmd = self.kernel_spec.argv + extra_arguments
  
      if cmd and cmd[0] in {
          "python",
          "python%i" % sys.version_info[0],
          "python%i.%i" % sys.version_info[:2],
      }:
          # executable is 'python' or 'python3', use sys.executable.
          # These will typically be the same,
          # but if the current process is in an env
          # and has been launched by abspath without
          # activating the env, python on PATH may not be sys.executable,
          # but it should be.
          cmd[0] = sys.executable
  
      # Make sure to use the realpath for the connection_file
      # On windows, when running with the store python, the connection_file path
      # is not usable by non python kernels because the path is being rerouted when
      # inside of a store app.
      # See this bug here: https://bugs.python.org/issue41196
      ns: t.Dict[str, t.Any] = {
          "connection_file": os.path.realpath(self.connection_file),
          "prefix": sys.prefix,
      }
  
      if self.kernel_spec:  # type:ignore[truthy-bool]
          ns["resource_dir"] = self.kernel_spec.resource_dir
      assert isinstance(self._launch_args, dict)
  
      ns.update(self._launch_args)
  
      pat = re.compile(r"\{([A-Za-z0-9_]+)\}")
  
      def from_ns(match: t.Any) -> t.Any:
          """Get the key out of ns if it's there, otherwise no change."""
          return ns.get(match.group(1), match.group())
  
      return [pat.sub(from_ns, arg) for arg in cmd]
  
imports: import asyncio
  import functools
  import os
  import re
  import signal
  import sys
  import typing
  import uuid
  import warnings
  from asyncio.futures import Future
  from concurrent.futures import Future
  from contextlib import contextmanager
  from enum import Enum
  import zmq
  from jupyter_core.utils import run_sync
  from traitlets import Any, Bool, Dict, DottedObjectName, Float, Instance, Type, Unicode, default, observe, observe_compat
  from traitlets.utils.importstring import import_item
  from .None import kernelspec
  from .asynchronous import AsyncKernelClient
  from .blocking import BlockingKernelClient
  from .client import KernelClient
  from .connect import ConnectionFileMixin
  from .managerabc import KernelManagerABC
  from .provisioning import KernelProvisionerBase
  from .provisioning import KernelProvisionerFactory
label_desc: Use image node_id 19 for calling the KernelManager obj's underlying member method code with example usage: obj.format_kernel_cmd(extra_arguments) and returns: unknown, ns