Code Monkey home page Code Monkey logo

pygeometa's Introduction

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

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

pygeometa's People

Contributors

tomkralidis avatar alexandreleroux avatar rousseaulambertlp avatar acapparelli avatar alexfritz avatar kalxas avatar hugoledoux avatar jachym avatar neteler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.