parameters: (dist)
return_statement: return feed_parser.close()
docstring: :raises NoneMetadataError: if the distribution reports `has_metadata()`
          True but `get_metadata()` returns None.
docstring_summary: :raises NoneMetadataError: if the distribution reports `has_metadata()`
          True but `get_metadata()` returns None.
docstring_tokens: : raises NoneMetadataError : if the distribution reports has_metadata () True but get_metadata () returns None .
function: def get_metadata(dist):
      # type: (Distribution) -> Message
      """
      :raises NoneMetadataError: if the distribution reports `has_metadata()`
          True but `get_metadata()` returns None.
      """
      metadata_name = 'METADATA'
      if (isinstance(dist, pkg_resources.DistInfoDistribution) and
              dist.has_metadata(metadata_name)):
          metadata = dist.get_metadata(metadata_name)
      elif dist.has_metadata('PKG-INFO'):
          metadata_name = 'PKG-INFO'
          metadata = dist.get_metadata(metadata_name)
      else:
          logger.warning("No metadata found in %s", display_path(dist.location))
          metadata = ''
  
      if metadata is None:
          raise NoneMetadataError(dist, metadata_name)
  
      feed_parser = FeedParser()
      # The following line errors out if with a "NoneType" TypeError if
      # passed metadata=None.
      feed_parser.feed(metadata)
      return feed_parser.close()
function_tokens: def get_metadata ( dist ) : # type: (Distribution) -> Message metadata_name = 'METADATA' if ( isinstance ( dist , pkg_resources . DistInfoDistribution ) and dist . has_metadata ( metadata_name ) ) : metadata = dist . get_metadata ( metadata_name ) elif dist . has_metadata ( 'PKG-INFO' ) : metadata_name = 'PKG-INFO' metadata = dist . get_metadata ( metadata_name ) else : logger . warning ( "No metadata found in %s" , display_path ( dist . location ) ) metadata = '' if metadata is None : raise NoneMetadataError ( dist , metadata_name ) feed_parser = FeedParser ( ) # The following line errors out if with a "NoneType" TypeError if # passed metadata=None. feed_parser . feed ( metadata ) return feed_parser . close ( )