class_docstr: Extension of the completer class with IPython-specific features
class_docstr_tok: ["Extension","of","the","completer","class","with","IPython-specific","features"]
docstr: Match string keys in a dictionary, after e.g. 'foo[' 
docstr_tok: ["Match","string","keys","in","a","dictionary",",","after","e.g",".","'foo","[","'"]
code: def dict_key_matches(self, text):
      "Match string keys in a dictionary, after e.g. 'foo['"
  
      def get_keys(obj):
          # Objects can define their own completions by defining an
          # _ipy_key_completions_() method.
          method = get_real_method(obj, "_ipython_key_completions_")
          if method is not None:
              return method()
  
          # Special case some common in-memory dict-like types
          if isinstance(obj, dict) or _safe_isinstance(
              obj, "pandas", "DataFrame"
          ):
              try:
                  return list(obj.keys())
              except Exception:
                  return []
          elif _safe_isinstance(
              obj, "numpy", "ndarray"
          ) or _safe_isinstance(obj, "numpy", "void"):
              return obj.dtype.names or []
          return []
  
      try:
          regexps = self.__dict_key_regexps
      except AttributeError:
          dict_key_re_fmt = r"""(?x)
              (  # match dict-referring expression wrt greedy setting
                  %s
              )
              \[   # open bracket
              \s*  # and optional whitespace
              ([uUbB]?  # string prefix (r not handled)
                  (?:   # unclosed string
                      '(?:[^']|(?<!\\)\\')*
                  |
                      "(?:[^"]|(?<!\\)\\")*
                  )
              )?
              $
              """
          regexps = self.__dict_key_regexps = {
              False: re.compile(
                  dict_key_re_fmt
                  % """
                                    # identifiers separated by .
                                    (?!\d)\w+
                                    (?:\.(?!\d)\w+)*
                                    """
              ),
              True: re.compile(
                  dict_key_re_fmt
                  % """
                                   .+
                                   """
              ),
          }
  
      match = regexps[self.greedy].search(self.text_until_cursor)
      if match is None:
          return []
  
      expr, prefix = match.groups()
      try:
          obj = eval(expr, self.namespace)
      except Exception:
          try:
              obj = eval(expr, self.global_namespace)
          except Exception:
              return []
  
      keys = get_keys(obj)
      if not keys:
          return keys
      closing_quote, token_offset, matches = match_dict_keys(
          keys, prefix, self.splitter.delims
      )
      if not matches:
          return matches
  
      # get the cursor position of
      # - the text being completed
      # - the start of the key text
      # - the start of the completion
      text_start = len(self.text_until_cursor) - len(text)
      if prefix:
          key_start = match.start(2)
          completion_start = key_start + token_offset
      else:
          key_start = completion_start = match.end()
  
      # grab the leading prefix, to make sure all completions start with `text`
      if text_start > key_start:
          leading = ""
      else:
          leading = text[text_start:completion_start]
  
      # the index of the `[` character
      bracket_idx = match.end(1)
  
      # append closing quote and bracket as appropriate
      # this is *not* appropriate if the opening quote or bracket is outside
      # the text given to this method
      suf = ""
      continuation = self.line_buffer[len(self.text_until_cursor) :]
      if key_start > text_start and closing_quote:
          # quotes were opened inside text, maybe close them
          if continuation.startswith(closing_quote):
              continuation = continuation[len(closing_quote) :]
          else:
              suf += closing_quote
      if bracket_idx > text_start:
          # brackets were opened inside text, maybe close them
          if not continuation.startswith("]"):
              suf += "]"
  
      return [leading + k + suf for k in matches]
  
imports: from __future__ import print_function
  import __main__
  import glob
  import inspect
  import itertools
  import keyword
  import os
  import re
  import sys
  import unicodedata
  import string
  import warnings
  from traitlets.config.configurable import Configurable
  from IPython.core.error import TryNext
  from IPython.core.inputsplitter import ESC_MAGIC
  from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol
  from IPython.utils import generics
  from IPython.utils.decorators import undoc
  from IPython.utils.dir2 import dir2, get_real_method
  from IPython.utils.process import arg_split
  from IPython.utils.py3compat import builtin_mod, string_types, PY3, cast_unicode_py2
  from traitlets import Bool, Enum, observe
label_desc: Use image node_id 13 for calling the IPCompleter obj's underlying member method code with example usage: obj.dict_key_matches(text) and returns: unknown, list, list, keys, matches, method, list, unknown, list, list