docs: def resource_from_rdf(graph_or_distrib, dataset=None):
      '''
      Map a Resource domain model to a DCAT/RDF graph
      '''
      if isinstance(graph_or_distrib, RdfResource):
          distrib = graph_or_distrib
      else:
          node = graph_or_distrib.value(predicate=RDF.type,
                                        object=DCAT.Distribution)
          distrib = graph_or_distrib.resource(node)
  
      download_url = url_from_rdf(distrib, DCAT.downloadURL)
      access_url = url_from_rdf(distrib, DCAT.accessURL)
      url = safe_unicode(download_url or access_url)
  
      if dataset:
          resource = get_by(dataset.resources, 'url', url)
      if not dataset or not resource:
          resource = Resource()
          if dataset:
              dataset.resources.append(resource)
      resource.title = title_from_rdf(distrib, url)
      resource.url = url
      resource.description = sanitize_html(distrib.value(DCT.description))
      resource.filesize = rdf_value(distrib, DCAT.bytesSize)
      resource.mime = rdf_value(distrib, DCAT.mediaType)
      fmt = rdf_value(distrib, DCT.term('format'))
      if fmt:
          resource.format = fmt.lower()
      checksum = distrib.value(SPDX.checksum)
      if checksum:
          algorithm = checksum.value(SPDX.algorithm).identifier
          algorithm = CHECKSUM_ALGORITHMS.get(algorithm)
          if algorithm:
              resource.checksum = Checksum()
              resource.checksum.value = rdf_value(checksum, SPDX.checksumValue)
              resource.checksum.type = algorithm
  
      resource.published = rdf_value(distrib, DCT.issued, resource.published)
      resource.modified = rdf_value(distrib, DCT.modified, resource.modified)
  
      identifier = rdf_value(distrib, DCT.identifier)
      if identifier:
          resource.extras['dct:identifier'] = identifier
  
      if isinstance(distrib.identifier, URIRef):
          resource.extras['uri'] = distrib.identifier.toPython()
  
      return resource