class_docstr: Validate a metadata field.
  
  All _process_*() methods correspond to a core metadata field. The method is
  called with the field's raw value. If the raw value is valid it is returned
  in its "enriched" form (e.g. ``version.Version`` for the ``Version`` field).
  If the raw value is invalid, :exc:`InvalidMetadata` is raised (with a cause
  as appropriate).
class_docstr_tok: ["Validate","a","metadata","field",".","All","_process_","*","(",")","methods","correspond","to","a","core","metadata","field",".","The","method","is","called","with","the","field","'s","raw","value",".","If","the","raw","value","is","valid","it","is","returned","in","its","``","enriched","''","form","(","e.g",".","``","version.Version","``","for","the","``","Version","``","field",")",".","If","the","raw","value","is","invalid",",",":","exc",":","`","InvalidMetadata","`","is","raised","(","with","a","cause","as","appropriate",")","."]
code: def _process_description_content_type(self, value: str) -> str:
      content_types = {"text/plain", "text/x-rst", "text/markdown"}
      message = email.message.EmailMessage()
      message["content-type"] = value
  
      content_type, parameters = (
          # Defaults to `text/plain` if parsing failed.
          message.get_content_type().lower(),
          message["content-type"].params,
      )
      # Check if content-type is valid or defaulted to `text/plain` and thus was
      # not parseable.
      if (
          content_type not in content_types
          or content_type not in value.lower()
      ):
          raise self._invalid_metadata(
              f"{{field}} must be one of {list(content_types)}, not {value!r}"
          )
  
      charset = parameters.get("charset", "UTF-8")
      if charset != "UTF-8":
          raise self._invalid_metadata(
              f"{{field}} can only specify the UTF-8 charset, not {list(charset)}"
          )
  
      markdown_variants = {"GFM", "CommonMark"}
      variant = parameters.get(
          "variant", "GFM"
      )  # Use an acceptable default.
      if (
          content_type == "text/markdown"
          and variant not in markdown_variants
      ):
          raise self._invalid_metadata(
              f"valid Markdown variants for {{field}} are {list(markdown_variants)}, "
              f"not {variant!r}",
          )
      return value
  
imports: import email.feedparser
  import email.header
  import email.message
  import email.parser
  import email.policy
  import sys
  import typing
  from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, Type, Union, cast
  from .None import requirements, specifiers, utils, version
label_desc: Use image node_id 9 for calling the _Validator obj's underlying member method code with example usage: obj._process_description_content_type(value) and returns: value