class_docstr: Manages a single kernel in a subprocess on this host.
  
  This version starts kernels with Popen.
class_docstr_tok: ["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=None):
      """replace templated args (e.g. {connection_file})"""
      extra_arguments = extra_arguments or []
      if self.kernel_cmd:
          cmd = self.kernel_cmd + extra_arguments
      else:
          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
  
      ns = dict(
          connection_file=self.connection_file,
          prefix=sys.prefix,
      )
  
      if self.kernel_spec:
          ns["resource_dir"] = self.kernel_spec.resource_dir
  
      ns.update(self._launch_args)
  
      pat = re.compile(r"\{([A-Za-z0-9_]+)\}")
  
      def from_ns(match):
          """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: from __future__ import absolute_import
  from contextlib import contextmanager
  import os
  import re
  import signal
  import sys
  import time
  import warnings
  import zmq
  from ipython_genutils.importstring import import_item
  from .localinterfaces import is_local_ip, local_ips
  from traitlets import Any, Float, Instance, Unicode, List, Bool, Type, DottedObjectName
  from jupyter_client import launch_kernel, kernelspec
  from .connect import ConnectionFileMixin
  from .managerabc import KernelManagerABC
label_desc: Use image node_id 16 for calling the KernelManager obj's underlying member method code with example usage: obj.format_kernel_cmd(extra_arguments) and returns: unknown, ns