跳转到主要内容

FAIR数据点API客户端

项目描述

PyPI Documentation Status Build_Test Coverage Status Quality Gate Status

fairdatapoint-client

内容

概述

fairdatapoint-client是一个简单优雅的库,用于从Python与FAIR数据点资源交互,例如在FDP服务器中读取和写入目录、数据集和分布。

支持的API如下所示

FDP层 路径端点 特定资源端点
fdp [baseURL]或[baseURL]/fdp
目录 [baseURL]/目录 [baseURL]/目录/[目录ID]
数据集 [baseURL]/数据集 [baseURL]/数据集/[数据集ID]
分布 [baseURL]/分布 [baseURL]/分布/[分布ID]

安装

它需要Python版本3.7、3.8或3.9。

稳定版本

fairdatapoint-client可在PyPI上找到,您可以使用以下命令安装它

pip安装fairdatapoint-client

开发版本

您也可以从最新的源代码安装,但请注意,开发版本可能不稳定

git clone https://github.com/fair-data/fairdatapoint-client.git
cd fairdatapoint-client
pip install .

运行测试(包括覆盖率)

pip install '.[tests]'
pytest

教程

使用客户端

from fdpclient.client import Client

# create a client with base URL
client = Client('http://example.org')

# create metadata
with open('catalog01.ttl') as f:
    data = f.read()
client.create_catalog(data)

# let's assume the catalogID was assigned as 'catalog01'
# read metadata, return a RDF graph
r = client.read_catalog('catalog01')
print(r.serialize(format="turtle").decode("utf-8"))

# update metadata
with open('catalog01_update.ttl') as f:
    data_update = f.read()
client.update_catalog('catalog01', data_update)

# delete metadata
client.delete_catalog('catalog01')

使用操作函数

from fdpclient import operations

# create metadata
with open('catalog01.ttl') as f:
    data = f.read()
operations.create('http://example.org/catalog', data)

# read metadata, return a RDF graph
r = operations.read('http://example.org/catalog/catalog01')
print(r.serialize(format="turtle").decode("utf-8"))

# update metadata
with open('catalog01_update.ttl') as f:
    data_update = f.read()
operations.update('http://example.org/catalog/catalog01', data_update)

# delete metadata
operations.delete('http://example.org/catalog/catalog01')

问题和贡献

如果您有问题或发现错误,请通过Github问题频道报告问题。

如果您想为fairdatapoint-client的开发做出贡献,请查看贡献指南

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

fairdatapoint-client-0.1.0.tar.gz (12.7 kB 查看哈希值)

上传时间 源代码

构建分发

fairdatapoint_client-0.1.0-py3-none-any.whl (18.6 kB 查看哈希值)

上传时间 Python 3

由以下支持