pyinaturalist.formatters¶
Summary¶
|
Attempt to determine the model class corresponding to an API result |
|
If the given values are raw JSON responses, attempt to detect their type and convert to model objects |
|
Format model objects as a table. |
|
Pretty-print any model object or list into a condensed summary. |
|
Flatten out some nested data structures within observation records: |
Details¶
Utilities for formatting API responses and model objects, for convenience/readability when exploring data. Not used directly by API functions.
These functions will accept any of the following:
A JSON response
A list of response objects
A single response object
- pyinaturalist.formatters.detect_type(value)¶
Attempt to determine the model class corresponding to an API result
- pyinaturalist.formatters.ensure_model_list(values)¶
If the given values are raw JSON responses, attempt to detect their type and convert to model objects
- pyinaturalist.formatters.format_controlled_terms(obj, *, cls=<class 'pyinaturalist.models.controlled_term.ControlledTerm'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_identifications(obj, *, cls=<class 'pyinaturalist.models.identification.Identification'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_observations(obj, *, cls=<class 'pyinaturalist.models.observation.Observation'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_places(obj, *, cls=<class 'pyinaturalist.models.place.Place'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_projects(obj, *, cls=<class 'pyinaturalist.models.project.Project'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_search_results(obj, *, cls=<class 'pyinaturalist.models.search.SearchResult'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_species_counts(obj, *, cls=<class 'pyinaturalist.models.taxon.TaxonCount'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_table(values)¶
Format model objects as a table. If
rich
isn’t installed or the model doesn’t have a table format defined, just return a basic list of stringified objects.
- pyinaturalist.formatters.format_taxa(obj, *, cls=<class 'pyinaturalist.models.taxon.Taxon'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.format_users(obj, *, cls=<class 'pyinaturalist.models.user.User'>, **kwargs)¶
Generic function to format a response, object, or list of objects
- pyinaturalist.formatters.pprint(values)¶
Pretty-print any model object or list into a condensed summary.
Experimental: May also be used on most raw JSON API responses