code: def code_mapping(level, msg, default=99):
      
      try:
          return code_mappings_by_level[level][msg]
      except KeyError:
          pass
      # Following assumes any variable messages take the format
      # of 'Fixed text "variable text".' only:
      # e.g. 'Unknown directive type "req".'
      # ---> 'Unknown directive type'
      # e.g. 'Unknown interpreted text role "need".'
      # ---> 'Unknown interpreted text role'
      if msg.count('"') == 2 and ' "' in msg and msg.endswith('".'):
          txt = msg[: msg.index(' "')]
          return code_mappings_by_level[level].get(txt, default)
      return default
docs: Return an error code between 0 and 99.