• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

pygeometa/H11-Sep-2021-5,1764,193

pygeometa.egg-info/H03-May-2022-199148

LICENSE.mdH A D11-Jun-20201.8 KiB4434

MANIFEST.inH A D03-Sep-2021101 54

PKG-INFOH A D11-Sep-20217.6 KiB199148

README.mdH A D03-Sep-20215.4 KiB178127

setup.cfgH A D11-Sep-202138 53

setup.pyH A D11-Jun-20204.4 KiB13473

README.md

1[![Build Status](https://github.com/geopython/pygeometa/workflows/build%20%E2%9A%99%EF%B8%8F/badge.svg)](https://github.com/geopython/pygeometa/actions)
2[![Join the chat at https://gitter.im/geopython/pygeometa](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/geopython/pygeometa)
3
4# pygeometa
5
6[pygeometa](https://geopython.github.io/pygeometa) is a Python package to
7generate metadata for geospatial datasets.
8
9## Installation
10
11pygeometa is best installed and used within a Python virtualenv.
12
13### Requirements
14
15* Python 3 and above
16* Python [virtualenv](https://virtualenv.pypa.io/) package
17
18### Dependencies
19
20Dependencies are listed in [requirements.txt](requirements.txt). Dependencies
21are automatically installed during pygeometa's installation.
22
23### Installing the Package
24
25```bash
26python3 -m venv my-env
27cd my-env
28. bin/activate
29git clone https://github.com/geopython/pygeometa.git
30cd pygeometa
31python setup.py build
32python setup.py install
33```
34
35## Running
36
37### From the command line
38
39```bash
40# show all subcommands
41pygeometa
42
43# show all supported schemas
44pygeometa metadata schemas
45
46# provide a basic sanity check/report on an MCF
47pygeometa metadata info path/to/file.yml
48
49# generate an ISO 19139 document to stdout
50pygeometa metadata generate path/to/file.yml --schema=iso19139
51
52# generate an ISO 19139 document to disk
53pygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml
54
55# generate an ISO 19139 document to disk with debugging (ERROR, WARNING, INFO, DEBUG)
56pygeometa metadata generate path/to/file.yml --schema=iso19139 --output=some_file.xml --verbosity=DEBUG # add verbose (ERROR, WARNING, INFO, DEBUG)
57
58# use your own defined schema
59pygeometa metadata generate path/to/file.yml --schema_local=/path/to/my-schema --output=some_file.xml  # to file
60
61# validate your MCF
62pygeometa metadata validate path/to/file.yml
63```
64
65### Supported schemas
66Schemas supported by pygeometa:
67* dcat, [reference](https://www.w3.org/TR/vocab-dcat-2/)
68* iso19139, [reference](http://www.iso.org/iso/catalogue_detail.htm?csnumber=32557)
69* iso19139-hnap, [reference](http://www.gcpedia.gc.ca/wiki/Federal_Geospatial_Platform/Policies_and_Standards/Catalogue/Release/Appendix_B_Guidelines_and_Best_Practices/Guide_to_Harmonized_ISO_19115:2003_NAP)
70* OGC API - Records - Part 1: Core, record model, [reference](https://github.com/opengeospatial/ogcapi-records/blob/master/core/openapi/schemas/record.yaml)
71* SpatioTemporal Asset Catalog [(STAC)](https://stacspec.org)
72* iso19139-2, [reference](https://www.iso.org/standard/67039.html)
73* [wmo-cmp](doc/content/reference/formats/wmo-cmp.md), [reference](http://wis.wmo.int/2013/metadata/version_1-3-0/WMO_Core_Metadata_Profile_v1.3_Part_1.pdf)
74* [wmo-wigos](doc/content/reference/formats/wmo-wigos.md), [reference](https://library.wmo.int/opac/doc_num.php?explnum_id=3653)
75* Local schema, specified with ```--schema_local=/path/to/my-schema```
76
77### Using the API from Python
78
79```python
80from pygeometa.core import read_mcf, render_j2_template
81
82# read from disk
83mcf_dict = read_mcf('/path/to/file.yml')
84# read from string
85mcf_dict = read_mcf(mcf_string)
86
87# choose ISO 19139 output schema
88from pygeometa.schemas.iso19139 import ISO19139OutputSchema
89iso_os = ISO19139OutputSchema()
90
91# default schema
92xml_string = iso_os.write(mcf_dict)
93
94# user-defined schema
95xml_string = render_j2_template(mcf_dict, template_dir='/path/to/new-schema')
96
97# write to disk
98with open('output.xml', 'wb') as ff:
99    ff.write(xml_string)
100```
101
102## Development
103
104### Setting up a Development Environment
105
106Same as installing a package.  Use a virtualenv.  Also install developer
107requirements:
108
109```bash
110pip install -r requirements-dev.txt
111```
112
113### Adding a Metadata Schema to the Core
114
115Adding an output metadata schemas to pygeometa involves extending
116`pygeometa.schemas.base.BaseOutputSchema` and supporting the `write`
117function to return a string of exported metadata content.  If you are using
118Jinja2 templates, see the next section.  If you are using another means of
119generating metadata (lxml, xml.etree, json, etc.), override the ABS `write`
120class to emit a string using your tooling/workflow accordingly.  See the
121below sections for examples.
122
123Once you have added your metadata schema, you need to register it with
124pygeometa's schema registry:
125
126```bash
127vi pygeometa/schemas/__init__.py
128# edit the SCHEMAS dict with the metadata schema name and dotted path of class
129```
130
131#### Jinja2 templates
132
133To add support for a new metadata schema using Jinja2 templates:
134```bash
135cp -r pygeometa/schemas/iso19139 pygeometa/schemas/new-schema
136```
137Then modify `*.j2` files in the new `pygeometa/schemas/new-schema` directory
138to comply to new metadata schema.
139
140#### Custom tooling
141
142To add support for a new metadata schemas using other tooling/workflow:
143```bash
144mkdir pygeometa/schemas/foo
145cp pygeometa/schemas/iso19139/__init__.py pygeometa/schemas/foo
146vi pygeometa/schemas/foo/__init__.py
147# update class name and super().__init__() function accordingly
148
149### Running Tests
150
151```bash
152# via setuptools
153python setup.py test
154# manually
155cd tests
156python run_tests.py
157```
158
159## Releasing
160
161```bash
162python setup.py sdist bdist_wheel --universal
163twine upload dist/*
164```
165
166### Code Conventions
167
168* [PEP8](https://www.python.org/dev/peps/pep-0008)
169
170### Bugs and Issues
171
172All bugs, enhancements and issues are managed on [GitHub](https://github.com/geopython/pygeometa/issues).
173
174## Contact
175
176* [Tom Kralidis](https://github.com/tomkralidis)
177* [Alexandre Leroux](https://github.com/alexandreleroux)
178