pyinaturalist.formatters module

Extra functions to help preview response content, 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

They will also accept the option align=True to align values where possible.

pyinaturalist.formatters.format_controlled_terms(terms, align=False)[source]

Format controlled term results into a condensed list of terms and values

Return type

str

Parameters
  • terms (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_identifications(identifications, align=False)[source]

Format identification results into a condensed summary: id, what, when, and who

Return type

str

Parameters
  • identifications (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_observations(observations, align=False)[source]

Format observation results into a condensed summary: id, what, when, who, and where

Return type

str

Parameters
  • observations (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_places(places, align=False)[source]

Format place results into a condensed list of IDs and names

Return type

str

Parameters
  • places (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_projects(projects, align=False)[source]

Format project results into a condensed list of IDs and titles

Return type

str

Parameters
  • projects (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_search_results(search_results, align=False)[source]

Format search results into a condensed list of values depending on result type

Return type

str

Parameters
  • search_results (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_species_counts(species_counts, align=False)[source]

Format observation species counts into a condensed list of names and # of observations

Return type

str

Parameters
  • species_counts (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_taxa(taxa, align=False)[source]

Format taxon results into a single string containing taxon ID, rank, and name (including common name, if available).

Return type

str

Parameters
  • taxa (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.format_users(users, align=False)[source]

Format user results into a condensed list of IDs, usernames, and real names

Return type

str

Parameters
  • users (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –

pyinaturalist.formatters.simplify_observations(observations, align=False)[source]

Flatten out some nested data structures within observation records:

  • annotations

  • comments

  • identifications

  • non-owner IDs

Return type

List[Dict[str, Any]]

Parameters
  • observations (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) –

  • align (bool) –