Skip to main content

pygeometa is a Python package to generate metadata for geospatial datasets

Project description

Build Status Join the chat at https://gitter.im/geopython/pygeometa

pygeometa

pygeometa is a Python package to generate metadata for geospatial datasets.

Installation

pygeometa is best installed and used within a Python virtualenv.

Requirements

Dependencies

Dependencies are listed in requirements.txt. Dependencies are automatically installed during pygeometa's installation.

Installing the Package

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

Running

From the command line

# 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

Supported schemas

Schemas supported by pygeometa:

Using the API from Python

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)

Development

Setting up a Development Environment

Same as installing a package. Use a virtualenv. Also install developer requirements:

pip install -r requirements-dev.txt

Adding a Metadata Schema to the Core

Adding an output metadata schemas to pygeometa involves extending pygeometa.schemas.base.BaseOutputSchema and supporting the write function to return a string of exported metadata content. If you are using Jinja2 templates, see the next section. If you are using another means of generating metadata (lxml, xml.etree, json, etc.), override the ABS write class to emit a string using your tooling/workflow accordingly. See the below sections for examples.

Once you have added your metadata schema, you need to register it with pygeometa's schema registry:

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

Jinja2 templates

To add support for a new metadata schema using Jinja2 templates:

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

Then modify *.j2 files in the new pygeometa/schemas/new-schema directory to comply to new metadata schema.

Custom tooling

To add support for a new metadata schemas using other tooling/workflow:

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 

### Running Tests

```bash
# via setuptools
python setup.py test
# manually
cd tests
python run_tests.py

Releasing

# update version
vi pygeometa/__init__.py
git commit -m 'update release version' pygeometa/__init__.py
vi debian/changelog  # add changelog entry and summary of updates
# 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
python setup.py sdist bdist_wheel --universal
twine upload dist/*

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygeometa-0.12.0.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

pygeometa-0.12.0-py2.py3-none-any.whl (72.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pygeometa-0.12.0.tar.gz.

File metadata

  • Download URL: pygeometa-0.12.0.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.8

File hashes

Hashes for pygeometa-0.12.0.tar.gz
Algorithm Hash digest
SHA256 757b10a2b14bf4a07021f8a3e9f782caee5cfb9ffbec6853a3a3a348bbd3c763
MD5 743c162f65768be33943ac91bc8e6232
BLAKE2b-256 1bcb8e1677023110bed12917d44efe0c42abb79f21e373ff6342c55e06eea6b2

See more details on using hashes here.

Provenance

File details

Details for the file pygeometa-0.12.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pygeometa-0.12.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 72.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.8

File hashes

Hashes for pygeometa-0.12.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 90de681a240c8468337060872a49e5eba5ed34274649cd7109682182e944a947
MD5 9ea0089fae104d9582c7dd1873f4e8fe
BLAKE2b-256 54b35daf5ba612ac63fad29383bec9f47fe026c27ce154200439673cf7739b2e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page