parameters: (dist)
docstring: Obtain a DirectUrl from a pkg_resource.Distribution.
  
  
  
      Returns None if the distribution has no `direct_url.json` metadata,
  
      or if `direct_url.json` is invalid.
docstring_summary: Obtain a DirectUrl from a pkg_resource.Distribution.
docstring_tokens: Obtain a DirectUrl from a pkg_resource . Distribution .
function: def dist_get_direct_url(dist):
  
      # type: (Distribution) -> Optional[DirectUrl]
  
      """Obtain a DirectUrl from a pkg_resource.Distribution.
  
  
  
      Returns None if the distribution has no `direct_url.json` metadata,
  
      or if `direct_url.json` is invalid.
  
      """
  
      if not dist.has_metadata(DIRECT_URL_METADATA_NAME):
  
          return None
  
      try:
  
          return DirectUrl.from_json(dist.get_metadata(DIRECT_URL_METADATA_NAME))
  
      except (
  
          DirectUrlValidationError,
  
          json.JSONDecodeError,
  
          UnicodeDecodeError
  
      ) as e:
  
          logger.warning(
  
              "Error parsing %s for %s: %s",
  
              DIRECT_URL_METADATA_NAME,
  
              dist.project_name,
  
              e,
  
          )
  
          return None
function_tokens: def dist_get_direct_url ( dist ) : # type: (Distribution) -> Optional[DirectUrl] if not dist . has_metadata ( DIRECT_URL_METADATA_NAME ) : return None try : return DirectUrl . from_json ( dist . get_metadata ( DIRECT_URL_METADATA_NAME ) ) except ( DirectUrlValidationError , json . JSONDecodeError , UnicodeDecodeError ) as e : logger . warning ( "Error parsing %s for %s: %s" , DIRECT_URL_METADATA_NAME , dist . project_name , e , ) return None