跳转到主要内容

一个映射CKAN元数据与Frictionless元数据的库。

项目描述

Frictionless CKAN Mapper

一个映射CKAN元数据与Frictionless元数据的库。

该库没有依赖项(甚至不包括数据包库)。您可以直接使用它,或者将其作为灵感来源。算法的详细说明在文档中,您也可以阅读代码。

Travis Coveralls PyPi SemVer Chat on Discord

安装

  • Python:安装Python。该库与Python 2.7+和Python 3.3+兼容。
pip install frictionless-ckan-mapper

注意:该包作为frictionless-ckan-mapper安装,然后作为frictionless_ckan_mapper导入。

入门

CKAN => 无摩擦

# get a CKAN metadata item
ckan_dataset = {
  "name": "my-dataset",
  "title": "My awesome dataset",
  "url": "http://www.example.com/data.csv"
}

# or load from an API e.g.
# ckan_dataset = json.load(urllib.urlopen(
#     https://demo.ckan.org/api/3/package_show?id=my_dataset
# ))

from frictionless_ckan_mapper import ckan_to_frictionless as converter

# convert to frictionless
frictionless_package = converter.dataset(ckan_dict)

print(frictionless_package)

无摩擦 => CKAN

frictionless = {
  'name': "f11s-dataset",
  'path': "https://datahub.io/data.csv"
}

from frictionless_ckan_mapper import frictionless_to_ckan as f2c

ckanout = f2c.dataset(frictionless)

print(ckanout)

参考

此包包含两个模块

  • frictionless_to_ckan
  • ckan_to_frictionless

您可以直接导入它们,如下所示

from frictionless_ckan_mapper import ckan_to_frictionless
from frictionless_ckan_mapper import frictionless_to_ckan

ckan_to_frictionless

resource(ckandict)

from frictionless_ckan_mapper import ckan_to_frictionless as converter

# ... Some code with a CKAN dictionary ...

output_frictionless_dict = converter.resource(ckan_dictionary)

dataset(ckandict)

from frictionless_ckan_mapper import ckan_to_frictionless as converter

# ... Some code with a CKAN dictionary ...

output_frictionless_dict = converter.dataset(ckan_dictionary)

frictionless_to_ckan

resource(fddict)

from frictionless_ckan_mapper import frictionless_to_ckan as converter

# ... Some code with a Frictionless dictionary ...

output_ckan_dict = converter.resource(frictionless_dictionary)

package(fddict)

from frictionless_ckan_mapper import frictionless_to_ckan as converter

# ... Some code with a Frictionless dictionary ...

output_ckan_dict = converter.package(frictionless_dictionary)

设计

Frictionless   <=>        CKAN
--------------------------------------
Data Package   <=>   Package (Dataset)
Data Resource  <=>   Resource
Table Schema   <=>   Data Dictionary?? (datastore resources can have schemas)

CKAN参考

摘要

classDiagram

class Package
class Resource
class DataDictionary

Package *-- Resource
Resource o-- DataDictionary

mermaid-diagram-20200703112520

CKAN元数据结构的源

算法:CKAN => 无摩擦

frictionless_ckan_mapper/ckan_to_frictionless.py中查看代码

算法:无摩擦 => CKAN

frictionless_ckan_mapper/frictionless_to_ckan.py中查看代码

开发者

安装源代码

  • 克隆仓库

    git clone https://github.com/frictionlessdata/frictionless-ckan-mapper.git
    
  • 然后使用pip安装它

    pip install -e .
    

运行测试

使用出色的pytest套件,如下所示

pytest tests

为了在Python 2和Python 3环境中进行测试,我们使用tox。您可以运行以下命令

make test

注意:请确保您的环境中包含必要的Python版本PATH(Python 2.7和Python 3.6)。

构建和发布包

要查看Makefile中可用的命令列表,请执行

make list

本地构建用于测试的发行包

如果存在先前的构建,请确保在重新构建之前将其删除

make distclean

然后

make dist

或者,此命令将构建Python 2和Python 3的包

python setup.py sdist bdist_wheel --universal

在test.pypi.org测试包

python -m twine upload --repository testpypi dist/*

该包将在https://test.pypi.org/project/frictionless-ckan-mapper/上公开可用,并且您可以使用通常的方法pip install

标记新的Git版本并发布到官方PyPi

请确保更新文件frictionless_ckan_mapper/VERSION中包的版本。然后

make release

您可以使用make version快速查看要发布的版本,它将打印存储在VERSION中的当前版本。

项目详情


下载文件

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

源分布

frictionless-ckan-mapper-1.0.9.tar.gz (16.2 KB 查看散列

上传于

构建分发

frictionless_ckan_mapper-1.0.9-py2.py3-none-any.whl (9.7 kB 查看哈希)

上传于 Python 2 Python 3

由以下支持