ckan - 在 CKAN 中获取包的 HarvestSource
问题描述
根据数据集包的 id,我如何确定包是否被收割、由哪个收割机以及该收割机的基本 URL 是什么?
类似于以下内容:
guid = '65715c6e-bbaf-3def-982b-3b5156272da7'
harvest_source = getHarvestSource(guid)
if (harvest_source):
type = harvest_source.type() # whatever was set as the name attribute for this harvester class
base_url = harvest_source.url() # whatever was set as the URL in the admin interface
解决方案
我还没有尝试过,但是通过阅读模型,我期望得到这样的结果:
from ckan.model import Package
id = u'65715c6e-bbaf-3def-982b-3b5156272da7'
dataset = model.Package.get(id)
dataset_was_harvested = bool(len(dataset.harvest_objects) > 0)
if dataset_was_harvested:
ho = dataset.harvest_objects[0] # there's not usually more than 1
source = ho.source # i.e. the harvest source is "the harvester"
source.url # i.e. the harvester's base url
source.type # is also useful
推荐阅读
- r - 在R中重构字符串
- arrays - 无法使用 uint8 类型初始化数组
- apache-kafka - cli 模式下的 Quarkus Kafka
- python - 如何在 Python 中按字母顺序对文件进行排序
- javascript - 如何在 nodeValue 中插入 span 元素
- c++ - 无法在 C++ 中初始化静态成员
- c++ - C++:创建模板结构的 C++ 向量
- typescript - 如何在 TypeScript 中使用模板文字类型作为返回类型属性
- crystal-reports - Crystal Reports 的额外页面
- python - 如何将带有法国口音和表情符号的 CSV 上传到 Google 表格?