pymangal
is a python
module to interact with the mangal
API. The
documentation is here: http://pymangal.readthedocs.org/en/latest/
ALL numbered versions are pushed to PyPI, so you can at all time install with pip install pymangal
.
In no particular order
networkx
export- Automated handling of
related
fields (appendprefix
) signUp
method
Follows semantic versioning. The version is given in the
__version__
variable of pymangal
. Most important releases are tagged.
Contrary to the rmangal
package, this module focuses on implementing a
minimal set of functions. it's a little less user-friendly, but easier to
maintain (and learn).
Dialogue with the API is handled by an instance of the mangal
class. The
four most important functions are List
, Get
, Post
, and Patch
(to,
respectively, see a list of data, get a particular record, add new data,
and patch them).
Unlike in the R package, there is a validation of the data done automatically before the data are either posted or patched.
import pymangal
# We create an instance of the mangal class
db = pymangal.mangal()
# Arguments: url, usr, pwd
# Returns the first 20 datasets
db.List('dataset')
# Returns all datasets
db.List('dataset', page='all')
# Returns all taxa matching *vulgaris
db.List('taxa', filters='name__endswith=vulgaris', page='all')
# Get the first network
db.get('network', 1)
# Objects are represented as dict
taxa = {'name': 'Pisaster ochraceus', 'vernacular': 'purple sea star',
'status': 'confirmed', 'eol': '598469'}
# You need to have a username/API key to add and patch objects
db_auth = pymangal.mangal(usr='test', key='dsdsdsdsdsds')
taxa = db_auth.Post('taxa', taxa)
print taxa['id']