diff --git a/.gitignore b/.gitignore index d79ee0a9..f82fec7f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,6 @@ test.py tests.sh .gitpod.yml -.vscode -.pytest_cache -Function_Changes.md \ No newline at end of file +EXAMPLES.md +Function_Changes.md +.vscode \ No newline at end of file diff --git a/README.rst b/README.rst index 2b1c818f..72d72f97 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,7 @@ pyobis Python client for the `OBIS API `__. -`Source on GitHub at iobis/pyobis `__ +`Source Code here `__ Other OBIS clients: @@ -28,7 +28,7 @@ dev version pip install git+git://github.com/sckott/pyobis.git#egg=pyobis -library API +Library API =========== `pyobis` is split up into modules for each of the groups of API methods. @@ -39,6 +39,11 @@ library API * `nodes` - Nodes * `checklist` - Checklist + + +Usage +=========== + You can import the entire library, or each module individually as needed. Taxa module @@ -83,7 +88,7 @@ Dataset module from pyobis import dataset dataset.search(scientificname = ['Mola', 'Abra', 'Lanice', 'Pectinaria']) - dataset.get(id = 'ec9df3b9-3b2b-4d83-881b-27bcbcd57b95') + dataset.get(id = 2126) Nodes module =========== @@ -104,7 +109,7 @@ Checklist module Meta ==== -* License: MIT, see `LICENSE file `__ +* License: MIT, `see LICENSE file `__ * Please note that this project is released with a `Contributor Code of Conduct `__. By participating in this project you agree to abide by its terms. .. |pypi| image:: https://img.shields.io/pypi/v/pyobis.svg @@ -113,8 +118,8 @@ Meta .. |docs| image:: https://readthedocs.org/projects/pyobis/badge/?version=latest :target: http://pyobis.readthedocs.org/en/latest/?badge=latest -.. |tests| image:: https://github.com/ayushanand18/pyobis/actions/workflows/tests.yml/badge.svg - :target: https://github.com/ayushanand18/pyobis/actions/workflows/tests.yml +.. |tests| image:: https://github.com/iobis/pyobis/actions/workflows/tests.yml/badge.svg + :target: https://github.com/iobis/pyobis/actions/workflows/tests.yml .. |coverage| image:: https://coveralls.io/repos/sckott/pyobis/badge.svg?branch=master&service=github - :target: https://coveralls.io/github/sckott/pyobis?branch=gsoc2022 + :target: https://coveralls.io/github/sckott/pyobis?branch=master \ No newline at end of file diff --git a/pyobis/__init__.py b/pyobis/__init__.py index b9818fc2..376f99f7 100644 --- a/pyobis/__init__.py +++ b/pyobis/__init__.py @@ -5,8 +5,11 @@ ''' pyobis library ~~~~~~~~~~~~~~~~~~~~~ + pyobis is a Python client for OBIS. + Example usage: + # Import entire library import pyobis # or import modules as needed @@ -18,6 +21,7 @@ from pyobis import dataset ## checklist from pyobis import checklist + ## use advanced logging ### setup first import requests @@ -40,7 +44,7 @@ __license__ = 'MIT' from .occurrences import search, get, grid, getpoints, point, tile, centroid, download, ObisDownload -from .taxa import search, taxon, annotations +from .taxa import search, taxon, annotations, common, taxon_search from .nodes import search, activities from .dataset import get, search from .checklist import list, redlist, newest \ No newline at end of file diff --git a/pyobis/taxa/taxa.py b/pyobis/taxa/taxa.py index 4c9556f4..4368c123 100644 --- a/pyobis/taxa/taxa.py +++ b/pyobis/taxa/taxa.py @@ -5,7 +5,7 @@ def search(scientificname=None, **kwargs): Get taxon records. :param scientificname: [String,Array] One or more scientific names from the OBIS backbone. All included and synonym taxa are included in the search. - + :return: A dictionary Usage:: @@ -41,18 +41,61 @@ def taxon(id, **kwargs): out = obis_GET(url, {}, 'application/json; charset=utf-8', **kwargs) return out -def annotations(scientificname=None, **kwargs): +def annotations(scientificname, **kwargs): ''' Get scientific name annotations by the WoRMS team. :param scientificname: [String] Scientific name. Leave empty to include all taxa. - :return: A dictionary Usage:: from pyobis import taxa - taxa.annotations('Abra') + taxa.annotations(Abra) ''' url = obis_baseurl + 'taxon/annotations' scientificname = handle_arrstr(scientificname) out = obis_GET(url, {'scientificname':scientificname}, 'application/json; charset=utf-8', **kwargs) return out + +def taxon_search(scientificname=None, aphiaid=None, obisid=None, **kwargs): + ''' + This function has become obsolete. + + :param id: [Fixnum] An OBIS taxon identifier + + :return: A dictionary + + Usage:: + + from pyobis import taxa + taxa.taxon_search(scientificname = 'Mola mola') + taxa.taxon_search(scientificname = 'Mola') + taxa.taxon_search(aphiaid = 127405) + taxa.taxon_search(obisid = 472375) + ''' + url = obis_baseurl + 'taxon/' + handle_arrstr(scientificname) + out = obis_GET(url, {'aphiaid': aphiaid, 'obisid': obisid, + 'scientificname': scientificname}, 'application/json; charset=utf-8', **kwargs) + return out + +def common(id, **kwargs): + ''' + This function has become obsolete. + + Get common names for a taxon by ID + + :param id: [Fixnum] An OBIS taxon identifier. Required + + :return: A dictionary + + Usage:: + + from pyobis import taxa + # have common names + taxa.common(402913) + taxa.common(406296) + # no common names + taxa.common(415282) + ''' + url = obis_baseurl + 'taxon/' + str(id) + '/common' + out = obis_GET(url, {}, 'application/json; charset=utf-8', **kwargs) + return out \ No newline at end of file