跳转到主要内容

pygeometa是一个用于生成地理空间数据集元数据的Python包

项目描述

Build Status Join the chat at https://matrix.to/#/#geopython_pygeometa:gitter.im

pygeometa

pygeometa是一个用于生成地理空间数据集元数据的Python包。

安装

pygeometa最好在Python虚拟环境中安装和使用。

要求

依赖项

依赖项列在requirements.txt中。依赖项将在安装pygeometa时自动安装。

安装包

python3 -m venv my-env
cd my-env
. bin/activate
git clone https://github.com/geopython/pygeometa.git
cd pygeometa
python3 setup.py build
python3 setup.py install

运行

从命令行

# show all subcommands
pygeometa

# show all supported schemas
pygeometa metadata schemas

# provide a basic sanity check/report on an MCF
pygeometa metadata info path/to/file.yml

# generate an ISO 19139 document to stdout
pygeometa metadata generate path/to/file.yml --schema=iso19139

# generate an ISO 19139 document to disk
pygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml

# generate an ISO 19139 document to disk with debugging (ERROR, WARNING, INFO, DEBUG)
pygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml --verbosity=DEBUG # add verbose (ERROR, WARNING, INFO, DEBUG)

# use your own defined schema
pygeometa metadata generate path/to/file.yml --schema_local=/path/to/my-schema --output=some_file.xml  # to file

# validate your MCF
pygeometa metadata validate path/to/file.yml

# import a metadata document to MCF
pygeometa metadata import path/to/file.xml --schema=iso19139

# transform from one metadata representation to another
pygeometa metadata transform path/to/file.xml --input-schema=iso19139 --output-schema=oarec-record

支持的架构

pygeometa支持的架构

从Python中使用API

from pygeometa.core import read_mcf, render_j2_template

# read from disk
mcf_dict = read_mcf('/path/to/file.yml')
# read from string
mcf_dict = read_mcf(mcf_string)

# choose ISO 19139 output schema
from pygeometa.schemas.iso19139 import ISO19139OutputSchema
iso_os = ISO19139OutputSchema()

# default schema
xml_string = iso_os.write(mcf_dict)

# user-defined schema
xml_string = render_j2_template(mcf_dict, template_dir='/path/to/new-schema')

# write to disk
with open('output.xml', 'wb') as ff:
    ff.write(xml_string)

开发

设置开发环境

与安装包相同。使用虚拟环境。还需要安装开发者依赖

pip3 install -r requirements-dev.txt

将元数据模式添加到核心

将输出元数据模式添加到pygeometa涉及扩展pygeometa.schemas.base.BaseOutputSchema并支持write函数以返回导出元数据内容的字符串。如果您正在使用Jinja2模板,请参阅下一节。如果您正在使用其他生成元数据的方法(lxml,xml.etree,json等),则覆盖ABS write类以使用您的工具/工作流程相应地发出字符串。请参阅下面的示例。

一旦您添加了元数据模式,您需要将其注册到pygeometa的方案注册表中

vi pygeometa/schemas/__init__.py
# edit the SCHEMAS dict with the metadata schema name and dotted path of class

Jinja2模板

要使用Jinja2模板添加对新元数据模式的支持

cp -r pygeometa/schemas/iso19139 pygeometa/schemas/new-schema

然后修改*.j2文件在新pygeometa/schemas/new-schema目录中,以符合新的元数据模式。

自定义工具

要使用其他工具/工作流程添加对新元数据模式的支持

mkdir pygeometa/schemas/foo
cp pygeometa/schemas/iso19139/__init__.py pygeometa/schemas/foo
vi pygeometa/schemas/foo/__init__.py
# update class name and super().__init__() function accordingly 

运行测试

# via setuptools
python3 setup.py test
# manually
cd tests
python3 run_tests.py

发布

# update version
vi pygeometa/__init__.py
vi debian/changelog  # add changelog entry and summary of updates
git commit -m 'update release version' pygeometa/__init__.py debian/changelog
# push changes
git push origin master
git tag -a x.y.z -m 'tagging release x.y.z'
# push tag
git push --tags
rm -fr build dist *.egg-info
python3 setup.py sdist bdist_wheel --universal
twine upload dist/*

代码约定

错误和问题

所有错误、增强和问题都在GitHub上管理。

联系方式

项目详情


下载文件

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

源代码分发

pygeometa-0.16.1.tar.gz (59.9 kB 查看哈希值)

上传时间 源代码

构建分发

pygeometa-0.16.1-py2.py3-none-any.whl (79.6 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面