Formatters¶
Summary¶
Classes
Functions
|
Attempt to determine the model class corresponding to an API result |
|
Configure logging to standard output with prettier tracebacks, formatting, and terminal colors (if supported). |
|
If the given values are raw JSON responses, attempt to detect their type and convert to model objects |
|
Format HTTP request info |
|
Format HTTP response info, including whether it came from the cache |
|
Format model objects as a table. |
|
Format a taxon and its descendants as a tree |
|
Pretty-print any model object or list into a condensed summary. |
|
Pretty-print a taxon and its descendants as a tree. |
Module Contents¶
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.enable_logging(level='INFO', external_level='WARNING')¶
Configure logging to standard output with prettier tracebacks, formatting, and terminal colors (if supported).
If you prefer, logging can be configured with the stdlib
logging
module instead; this just provides some convenient defaults.
- 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_request(request, dry_run=False)¶
Format HTTP request info
- Return type:
- pyinaturalist.formatters.format_response(response)¶
Format HTTP response info, including whether it came from the cache
- Return type:
- pyinaturalist.formatters.format_table(values)¶
Format model objects as a table.
If the model doesn’t have a table format defined, return a basic list of stringified objects.
- pyinaturalist.formatters.format_tree(taxon, **kwargs)¶
Format a taxon and its descendants as a tree
- Return type:
Tree
- 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