pyinaturalist 0.17.0.dev1__tar.gz → 0.17.0.dev4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/HISTORY.md +10 -3
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/PKG-INFO +5 -5
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/README.md +2 -2
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/endpoints.md +1 -1
- pyinaturalist-0.17.0dev4/docs/images/open-in-vscode.svg +1 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/user_guide.md +8 -1
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/observation_photo_metadata.py +2 -1
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data.py +3 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/__init__.py +2 -1
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/auth.py +7 -5
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/client.py +11 -3
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/constants.py +9 -4
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/__init__.py +1 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/observations.py +19 -6
- pyinaturalist-0.17.0dev4/pyinaturalist/controllers/places.py +37 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/projects.py +22 -2
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/converters.py +7 -5
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/docs/templates.py +2 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/formatters.py +43 -40
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/__init__.py +11 -9
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/base.py +55 -6
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/controlled_term.py +51 -3
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/lazy_property.py +0 -5
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/observation.py +25 -6
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/photo.py +15 -2
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/place.py +1 -1
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/taxon.py +4 -2
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/paginator.py +71 -15
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/session.py +53 -10
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/__init__.py +1 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/observations.py +62 -33
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/places.py +17 -26
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/projects.py +18 -6
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyproject.toml +11 -12
- pyinaturalist-0.17.0dev4/setup.py +59 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/controllers/test_observation_controller.py +14 -0
- pyinaturalist-0.17.0dev4/test/controllers/test_place_controller.py +73 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/controllers/test_project_controller.py +16 -0
- pyinaturalist-0.17.0dev4/test/sample_data/get_observation_popular_field_values.json +1260 -0
- pyinaturalist-0.17.0dev4/test/sample_data/get_observation_popular_field_values.py +352 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations_node_page1.json +1 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_converters.py +3 -3
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_formatters.py +50 -40
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_models.py +79 -5
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_session.py +34 -6
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_observations.py +32 -16
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_places.py +5 -6
- pyinaturalist-0.17.0dev1/setup.py +0 -59
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/.readthedocs.yml +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/CONTRIBUTING.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/CONTRIBUTORS.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/LICENSE +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docker-compose.yml +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/collapsible_container.css +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/collapsible_container.js +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/colors.css +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/favicon.ico +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/pyinaturalist_logo.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/python-logo-green.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_static/table.css +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_templates/autosummary/module.rst_t +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_templates/autosummary_core/class.rst +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_templates/header.html +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_templates/localtoc.html +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_templates/module.rst_t +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/_templates/package.rst_t +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/automodapi.rst +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/code_of_conduct.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/conf.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/contributing.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/contributors.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/examples.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/history.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-new-application-complete.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-new-application.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-identifiers.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-observers.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-page-annotated.odg +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-page-annotated.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-page.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-search-bar.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-search-filters.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-observation-species-counts.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-taxon-autocomplete.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-taxon-page.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/inat-user-login.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/password_manager_keying.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pprint_table.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo.xcf +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo_hex.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo_hex.xcf +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo_med.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo_stacked.xcf +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo_white.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/pyinaturalist_logo_white.xcf +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/python-logo-green.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/images/python-logo-green.xcf +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/index.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/pyinaturalist.controllers.rst +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/pyinaturalist.models.rst +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/docs/reference.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Data Visualizations - Matplotlib.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Data Visualizations - Regional Activity Report.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Data Visualizations - Regional Observation Stats.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Data Visualizations - Seaborn.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/README.md +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Tutorial_1_Observations.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Tutorial_2_Taxa.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/Tutorial_3_Data_Visualizations.ipynb +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/__init__.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/combined_activity_stats.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/histogram_by_iconic_taxon.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/identifiers_by_month.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observation_image_grid.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observation_map.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observations_by_date_and_time.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observations_by_month.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observations_by_quality_grade.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observations_by_year.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/observers_by_month.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/taxa_by_month.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/total_observations_by_iconic_taxon.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/images/total_taxa_by_iconic_taxon.png +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/observations_to_gpx.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/observations_to_tsp.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data/fips_to_inat_place_ids.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data/observation_fields.parquet +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data/observations.gpx +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data/observations.tsp +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data/photo_info.html +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/sample_data/us_county_fips_codes.csv +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/base.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/taxa.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/users.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/docs/__init__.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/docs/docstrings.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/docs/emoji.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/docs/model_docs.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/docs/signatures.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/exceptions.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/comment.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/identification.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/life_list.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/message.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/observation_field.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/project.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/search.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/taxon_meta.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/models/user.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/node_api.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/py.typed +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/request_params.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/rest_api.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v0/__init__.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v0/observation_fields.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v0/observations.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/controlled_terms.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/identifications.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/messages.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/observation_fields.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/posts.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/search.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/taxa.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v1/users.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/v2/__init__.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/__init__.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/conftest.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/controllers/test_taxon_controller.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/controllers/test_user_controller.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/docs/test_docstrings.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/docs/test_signatures.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/add_project_observation.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/create_observation_fail.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/create_observation_result.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/create_observation_v1.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_access_token.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_access_token_401.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_all_observation_identifiers_ex_results.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_all_observation_observers_ex_results.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_all_observation_species_counts_ex_results.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_all_observation_species_counts_page1.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_all_observation_species_counts_page2.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_controlled_terms.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_controlled_terms_for_taxon.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_identifications.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_identifications.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_jwt.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_messages.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_nonexistent_observation.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_2.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_fields.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_fields_page1.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_fields_page2.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_day.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_day.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_hour.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_hour.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_month.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_month.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_month_of_year.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_month_of_year.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_week.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_week.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_week_of_year.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_histogram_week_of_year.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_identifiers_ex_results.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_identifiers_node_page1.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_identifiers_node_page2.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_observers_ex_results.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_observers_node_page1.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_observers_node_page2.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_species_counts.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_species_counts.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_taxon_summary.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_taxon_summary_conserved.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_taxon_summary_listed.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_taxonomy.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_with_ofvs.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_with_quality_metrics.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observation_with_sounds.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations.atom +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations.csv +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations.dwc +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations.js +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations.kml +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations_node.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_observations_node_page2.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_places_autocomplete.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_places_autocomplete.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_places_by_id.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_places_by_id.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_places_nearby.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_places_nearby.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_posts_login.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_posts_project.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_projects.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_projects.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_projects_by_id.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_projects_by_id.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_projects_obs_fields.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_search.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_search.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_autocomplete.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_autocomplete.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_autocomplete_minified.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_by_id.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_by_id.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_by_id_conservation_statuses.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_map_layers.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_with_all_names.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_taxa_with_preferred_place.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_user_by_id.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_user_by_id.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_users_autocomplete.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/get_users_autocomplete.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/obs_image.jpg +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/obs_sound.wav +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/post_observation_photos.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/post_observation_photos_list.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/post_observation_sounds.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/post_observation_sounds_list.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/post_put_observation_field_value.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/put_projects.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/update_observation_result.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/upload_photos.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/upload_photos_and_sounds.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data/upload_sounds.json +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/sample_data.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_auth.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_client.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_compat.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_paginator.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/test_request_params.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v0/test_observation_fields_v0.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v0/test_observations_v0.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_controlled_terms.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_identifications.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_messages.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_node_api.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_observation_fields.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_posts.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_projects.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_search.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_taxa.py +0 -0
- {pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/test/v1/test_users.py +0 -0
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
[See all Issues & PRs for 0.17](https://github.com/niconoe/pyinaturalist/milestone/8?closed=1)
|
|
5
5
|
|
|
6
6
|
### New Endpoints
|
|
7
|
+
* Added new **Observation** endpoint:
|
|
8
|
+
* `get_observation_popular_field_values()`
|
|
7
9
|
* Added new **Project** endpoint and helper functions:
|
|
8
10
|
* `update_project()`
|
|
9
11
|
* `add_project_users()`
|
|
@@ -12,6 +14,9 @@
|
|
|
12
14
|
### Modified Endpoints
|
|
13
15
|
* Updated `get_projects_by_id()` to allow string values (URL slugs) for `project_id`
|
|
14
16
|
* Updated `get_user_by_id()` to allow string values (usernames) for `user_id`
|
|
17
|
+
* Added support for setting timeout for individual API requests (with `timeout` parameter)
|
|
18
|
+
* Added support for setting cache timeout for individual API requests (with `expire_after` parameter)
|
|
19
|
+
* Added support for bypassing the cache for individual API requests (with `refresh` parameter)
|
|
15
20
|
|
|
16
21
|
### Authentication
|
|
17
22
|
* Added support for JWT authentication, which will now be used by default
|
|
@@ -21,9 +26,11 @@
|
|
|
21
26
|
|
|
22
27
|
### Other Changes
|
|
23
28
|
* Dropped support for python 3.6
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
* Updated rate limiting with a SQLite-based backend. This adds persistence for rate limit tracking
|
|
30
|
+
across multiple threads, processes, and/or application restarts. See
|
|
31
|
+
[pyrate-limiter docs](https://github.com/vutran1710/PyrateLimiter#sqlite) for more details.
|
|
32
|
+
* Add a `clear_cache()` function for clearing cached API responses
|
|
33
|
+
* Misc improvements for response pretty-printing
|
|
27
34
|
|
|
28
35
|
## 0.16.0 (2022-02-22)
|
|
29
36
|
[See all Issues & PRs for 0.16](https://github.com/niconoe/pyinaturalist/milestone/7?closed=1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyinaturalist
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.0dev4
|
|
4
4
|
Summary: iNaturalist API client for python
|
|
5
5
|
Home-page: https://github.com/niconoe/pyinaturalist
|
|
6
6
|
License: MIT
|
|
@@ -33,8 +33,8 @@ Requires-Dist: platformdirs (>=2.5)
|
|
|
33
33
|
Requires-Dist: python-dateutil (>=2.0)
|
|
34
34
|
Requires-Dist: python-forge (>=18.6)
|
|
35
35
|
Requires-Dist: requests (>=2.22)
|
|
36
|
-
Requires-Dist: requests-cache (
|
|
37
|
-
Requires-Dist: requests-ratelimiter (>=0.
|
|
36
|
+
Requires-Dist: requests-cache (>=1.0.0a0)
|
|
37
|
+
Requires-Dist: requests-ratelimiter (>=0.3.1)
|
|
38
38
|
Requires-Dist: rich (>=10.9)
|
|
39
39
|
Requires-Dist: sphinx (>=4.2.0,<5.0.0); extra == "docs"
|
|
40
40
|
Requires-Dist: sphinx-autodoc-typehints (>=1.17,<2.0); extra == "docs"
|
|
@@ -58,7 +58,7 @@ Description-Content-Type: text/markdown
|
|
|
58
58
|
[](https://pypi.org/project/pyinaturalist)
|
|
59
59
|
|
|
60
60
|
[](https://mybinder.org/v2/gh/niconoe/pyinaturalist/main?urlpath=lab/tree/examples)
|
|
61
|
-
[](https://open.vscode.dev/niconoe/pyinaturalist)
|
|
62
62
|
|
|
63
63
|
<br/>
|
|
64
64
|
|
|
@@ -139,7 +139,7 @@ On iNaturalist.org, this information can be found on the 'Species' tab of search
|
|
|
139
139
|
For example, to get the counts of all your own research-grade observations:
|
|
140
140
|
```python
|
|
141
141
|
>>> counts = get_observation_species_counts(user_id='my_username', quality_grade='research')
|
|
142
|
-
>>> pprint(counts
|
|
142
|
+
>>> pprint(counts)
|
|
143
143
|
[48473 ]: Species: Ganoderma applanatum (Artist's bracket): 4
|
|
144
144
|
[50310 ]: Species: Arisaema triphyllum (Jack-in-the-pulpit): 4
|
|
145
145
|
[50817 ]: Genus: Auricularia (Wood ear fungi): 3
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://pypi.org/project/pyinaturalist)
|
|
10
10
|
|
|
11
11
|
[](https://mybinder.org/v2/gh/niconoe/pyinaturalist/main?urlpath=lab/tree/examples)
|
|
12
|
-
[](https://open.vscode.dev/niconoe/pyinaturalist)
|
|
13
13
|
|
|
14
14
|
<br/>
|
|
15
15
|
|
|
@@ -90,7 +90,7 @@ On iNaturalist.org, this information can be found on the 'Species' tab of search
|
|
|
90
90
|
For example, to get the counts of all your own research-grade observations:
|
|
91
91
|
```python
|
|
92
92
|
>>> counts = get_observation_species_counts(user_id='my_username', quality_grade='research')
|
|
93
|
-
>>> pprint(counts
|
|
93
|
+
>>> pprint(counts)
|
|
94
94
|
[48473 ]: Species: Ganoderma applanatum (Artist's bracket): 4
|
|
95
95
|
[50310 ]: Species: Arisaema triphyllum (Jack-in-the-pulpit): 4
|
|
96
96
|
[50817 ]: Genus: Auricularia (Wood ear fungi): 3
|
|
@@ -39,7 +39,7 @@ For all available endpoints, see: <http://api.inaturalist.org/v1/docs/>
|
|
|
39
39
|
| GET | /observations/histogram | {py:func}`.get_observation_histogram`
|
|
40
40
|
| GET | /observations/identifiers | {py:func}`.get_observation_identifiers`
|
|
41
41
|
| GET | /observations/observers | {py:func}`.get_observation_observers`
|
|
42
|
-
| GET | /observations/popular_field_values |
|
|
42
|
+
| GET | /observations/popular_field_values | {py:func}`.get_observation_popular_field_values`
|
|
43
43
|
| GET | /observations/species_counts | {py:func}`.get_observation_species_counts`
|
|
44
44
|
| GET | /observations/taxonomy | {py:func}`.get_observation_taxonomy`
|
|
45
45
|
| GET | /places/{id} | {py:func}`.get_places_by_id`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="185" height="20" role="img" aria-label="Open in Visual Studio Code"><title>Open in Visual Studio Code</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="185" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="24" height="20" fill="#2c2c32"/><rect x="24" width="161" height="20" fill="#007acc"/><rect width="185" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMDA3YWNjIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+VmlzdWFsIFN0dWRpbyBDb2RlPC90aXRsZT48cGF0aCBkPSJNMjMuMTUgMi41ODdMMTguMjEuMjFhMS40OTQgMS40OTQgMCAwIDAtMS43MDUuMjlsLTkuNDYgOC42My00LjEyLTMuMTI4YS45OTkuOTk5IDAgMCAwLTEuMjc2LjA1N0wuMzI3IDcuMjYxQTEgMSAwIDAgMCAuMzI2IDguNzRMMy44OTkgMTIgLjMyNiAxNS4yNmExIDEgMCAwIDAgLjAwMSAxLjQ3OUwxLjY1IDE3Ljk0YS45OTkuOTk5IDAgMCAwIDEuMjc2LjA1N2w0LjEyLTMuMTI4IDkuNDYgOC42M2ExLjQ5MiAxLjQ5MiAwIDAgMCAxLjcwNC4yOWw0Ljk0Mi0yLjM3N0ExLjUgMS41IDAgMCAwIDI0IDIwLjA2VjMuOTM5YTEuNSAxLjUgMCAwIDAtLjg1LTEuMzUyem0tNS4xNDYgMTQuODYxTDEwLjgyNiAxMmw3LjE3OC01LjQ0OHYxMC44OTZ6Ii8+PC9zdmc+"/><text aria-hidden="true" x="1035" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="1510">Open in Visual Studio Code</text><text x="1035" y="140" transform="scale(.1)" fill="#fff" textLength="1510">Open in Visual Studio Code</text></g></svg>
|
|
@@ -360,11 +360,18 @@ To store the cache somewhere other than the default cache directory:
|
|
|
360
360
|
>>> session = ClientSession(cache_name='~/data/api_requests.db')
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
To
|
|
363
|
+
To manually clear the cache:
|
|
364
364
|
```python
|
|
365
365
|
>>> session.cache.clear()
|
|
366
366
|
```
|
|
367
367
|
|
|
368
|
+
Or as a shortcut, without a session object:
|
|
369
|
+
```python
|
|
370
|
+
from pyinaturalist import clear_cache
|
|
371
|
+
|
|
372
|
+
clear_cache()
|
|
373
|
+
```
|
|
374
|
+
|
|
368
375
|
## Rate Limiting
|
|
369
376
|
Rate limiting is applied to all requests so they stay within the rates specified by iNaturalist's
|
|
370
377
|
[API Recommended Practices](https://www.inaturalist.org/pages/api+recommended+practices).
|
{pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/examples/observation_photo_metadata.py
RENAMED
|
@@ -11,7 +11,8 @@ Also note that photo metadata is only visible to logged in users, so an access t
|
|
|
11
11
|
For more details on authentication, see:
|
|
12
12
|
|
|
13
13
|
* https://www.inaturalist.org/pages/api+reference#auth
|
|
14
|
-
* https://pyinaturalist.readthedocs.io/en/
|
|
14
|
+
* https://pyinaturalist.readthedocs.io/en/stable/user_guide.html#authentication
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
Extra dependencies:
|
|
17
18
|
``pip install beautifulsoup4``
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
"""Sample response data of every type to experiment with"""
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
|
+
from rich import print
|
|
7
|
+
|
|
6
8
|
from pyinaturalist import PROJECT_DIR, format_table, pprint
|
|
7
9
|
from pyinaturalist.models import *
|
|
8
10
|
|
|
@@ -56,3 +58,4 @@ tables = [
|
|
|
56
58
|
if __name__ == '__main__':
|
|
57
59
|
for table in tables:
|
|
58
60
|
pprint(table)
|
|
61
|
+
print(observation)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# flake8: noqa: F401, F403
|
|
2
|
+
# isort: skip_file
|
|
2
3
|
from logging import getLogger
|
|
3
4
|
|
|
4
5
|
logger = getLogger('pyinaturalist')
|
|
@@ -13,7 +14,7 @@ try:
|
|
|
13
14
|
from pyinaturalist.models import *
|
|
14
15
|
from pyinaturalist.paginator import Paginator, IDPaginator
|
|
15
16
|
from pyinaturalist.request_params import get_interval_ranges
|
|
16
|
-
from pyinaturalist.session import ClientSession
|
|
17
|
+
from pyinaturalist.session import ClientSession, clear_cache
|
|
17
18
|
from pyinaturalist.v0 import *
|
|
18
19
|
from pyinaturalist.v1 import *
|
|
19
20
|
from pyinaturalist.v2 import *
|
|
@@ -19,6 +19,7 @@ def get_access_token(
|
|
|
19
19
|
app_id: str = None,
|
|
20
20
|
app_secret: str = None,
|
|
21
21
|
jwt: bool = True,
|
|
22
|
+
refresh: bool = False,
|
|
22
23
|
) -> str:
|
|
23
24
|
"""Get an access token using the user's iNaturalist username and password, using the
|
|
24
25
|
Resource Owner Password Credentials Flow. Requires registering an iNaturalist app.
|
|
@@ -61,6 +62,7 @@ def get_access_token(
|
|
|
61
62
|
app_id: OAuth2 application ID
|
|
62
63
|
app_secret: OAuth2 application secret
|
|
63
64
|
jwt: Return a JSON Web Token; otherwise return an OAuth2 access token.
|
|
65
|
+
refresh: Do not use any cached tokens, even if they are not expired
|
|
64
66
|
|
|
65
67
|
Raises:
|
|
66
68
|
:py:exc:`requests.HTTPError`: (401) if credentials are invalid
|
|
@@ -68,7 +70,7 @@ def get_access_token(
|
|
|
68
70
|
# First check if we have a previously cached JWT
|
|
69
71
|
session = get_local_session()
|
|
70
72
|
response = _get_jwt(session, only_if_cached=True)
|
|
71
|
-
if response.ok:
|
|
73
|
+
if response.ok and not refresh:
|
|
72
74
|
logger.info('Using cached access token')
|
|
73
75
|
return response.json()['api_token']
|
|
74
76
|
|
|
@@ -84,10 +86,10 @@ def get_access_token(
|
|
|
84
86
|
# If any fields were missing, then check the keyring
|
|
85
87
|
if not all(payload.values()):
|
|
86
88
|
payload.update(get_keyring_credentials())
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
if all(payload.values()):
|
|
90
|
+
logger.info('Retrieved credentials from keyring')
|
|
91
|
+
else:
|
|
92
|
+
raise AuthenticationError('Not all authentication parameters were provided')
|
|
91
93
|
|
|
92
94
|
# Get OAuth access token
|
|
93
95
|
response = session.post(f'{API_V0_BASE_URL}/oauth/token', json=payload)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from logging import getLogger
|
|
2
|
-
from typing import Any, Callable, Dict
|
|
2
|
+
from typing import Any, Callable, Dict, Type
|
|
3
3
|
|
|
4
4
|
from requests import Session
|
|
5
5
|
|
|
@@ -7,6 +7,7 @@ from pyinaturalist.auth import get_access_token
|
|
|
7
7
|
from pyinaturalist.constants import JsonResponse
|
|
8
8
|
from pyinaturalist.controllers import (
|
|
9
9
|
ObservationController,
|
|
10
|
+
PlaceController,
|
|
10
11
|
ProjectController,
|
|
11
12
|
TaxonController,
|
|
12
13
|
UserController,
|
|
@@ -104,6 +105,7 @@ class iNatClient:
|
|
|
104
105
|
# Controllers
|
|
105
106
|
# TODO: Improve Sphinx docs generated for these attributes
|
|
106
107
|
self.observations = ObservationController(self) #: Interface for observation requests
|
|
108
|
+
self.places = PlaceController(self) #: Interface for project requests
|
|
107
109
|
self.projects = ProjectController(self) #: Interface for project requests
|
|
108
110
|
self.taxa = TaxonController(self) #: Interface for taxon requests
|
|
109
111
|
self.users = UserController(self) #: Interface for user requests
|
|
@@ -140,7 +142,12 @@ class iNatClient:
|
|
|
140
142
|
return request_function(**kwargs)
|
|
141
143
|
|
|
142
144
|
def paginate(
|
|
143
|
-
self,
|
|
145
|
+
self,
|
|
146
|
+
request_function: Callable,
|
|
147
|
+
model: T,
|
|
148
|
+
auth: bool = False,
|
|
149
|
+
cls: Type[Paginator] = Paginator,
|
|
150
|
+
**kwargs,
|
|
144
151
|
) -> Paginator[T]:
|
|
145
152
|
"""Create a paginator for a request, with client settings applied
|
|
146
153
|
|
|
@@ -148,7 +155,8 @@ class iNatClient:
|
|
|
148
155
|
request_function: The API request function to call, which should return a JSON response
|
|
149
156
|
model: Model class used for the response
|
|
150
157
|
auth: Indicates that the request requires authentication
|
|
158
|
+
cls: Alternative Paginator class to use
|
|
151
159
|
params: Original request parameters
|
|
152
160
|
"""
|
|
153
161
|
kwargs = self._update_kwargs(request_function, auth, **kwargs)
|
|
154
|
-
return
|
|
162
|
+
return cls(request_function, model, **kwargs)
|
|
@@ -10,12 +10,12 @@ from platformdirs import user_cache_dir
|
|
|
10
10
|
API_V0_BASE_URL = 'https://www.inaturalist.org'
|
|
11
11
|
API_V1_BASE_URL = 'https://api.inaturalist.org/v1'
|
|
12
12
|
API_V2_BASE_URL = 'https://api.inaturalist.org/v2'
|
|
13
|
-
DWC_ARCHIVE_URL = 'http://www.inaturalist.org/observations/gbif-observations-dwca.zip'
|
|
14
13
|
EXPORT_URL = 'https://www.inaturalist.org/observations/export'
|
|
15
14
|
INAT_BASE_URL = API_V0_BASE_URL
|
|
16
15
|
INAT_REPO = 'https://raw.githubusercontent.com/inaturalist/inaturalist/main'
|
|
17
16
|
ICONIC_TAXA_BASE_URL = f'{INAT_REPO}/app/assets/images/iconic_taxa'
|
|
18
17
|
PHOTO_BASE_URL = 'https://static.inaturalist.org/photos'
|
|
18
|
+
PHOTO_CC_BASE_URL = 'https://inaturalist-open-data.s3.amazonaws.com/photos'
|
|
19
19
|
PHOTO_INFO_BASE_URL = 'https://www.inaturalist.org/photos'
|
|
20
20
|
|
|
21
21
|
# Prefix used for keyring entries
|
|
@@ -49,12 +49,17 @@ SAMPLE_DATA_DIR = join(PROJECT_DIR, 'test', 'sample_data')
|
|
|
49
49
|
|
|
50
50
|
# Cache settings
|
|
51
51
|
CACHE_EXPIRATION = {
|
|
52
|
-
'api.inaturalist.org
|
|
53
|
-
'api.inaturalist.org/v*/
|
|
54
|
-
'api.inaturalist.org/v*/
|
|
52
|
+
'api.inaturalist.org/*autocomplete': timedelta(days=30),
|
|
53
|
+
'api.inaturalist.org/v*/controlled_terms*': timedelta(days=7),
|
|
54
|
+
'api.inaturalist.org/v*/places*': timedelta(days=7),
|
|
55
|
+
'api.inaturalist.org/v*/taxa*': timedelta(days=7),
|
|
56
|
+
f'{PHOTO_CC_BASE_URL}/*': -1,
|
|
57
|
+
f'{PHOTO_BASE_URL}/*': -1,
|
|
58
|
+
f'{ICONIC_TAXA_BASE_URL}/*': -1,
|
|
55
59
|
'*': timedelta(minutes=30),
|
|
56
60
|
}
|
|
57
61
|
CACHE_FILE = join(CACHE_DIR, 'api_requests.db')
|
|
62
|
+
RATELIMIT_FILE = join(CACHE_DIR, 'api_ratelimit.db')
|
|
58
63
|
TOKEN_EXPIRATION = timedelta(hours=1)
|
|
59
64
|
JWT_EXPIRATION = timedelta(days=1)
|
|
60
65
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# flake8: noqa: F401
|
|
3
3
|
from pyinaturalist.controllers.base import BaseController
|
|
4
4
|
from pyinaturalist.controllers.observations import ObservationController
|
|
5
|
+
from pyinaturalist.controllers.places import PlaceController
|
|
5
6
|
from pyinaturalist.controllers.projects import ProjectController
|
|
6
7
|
from pyinaturalist.controllers.taxa import TaxonController
|
|
7
8
|
from pyinaturalist.controllers.users import UserController
|
{pyinaturalist-0.17.0dev1 → pyinaturalist-0.17.0dev4}/pyinaturalist/controllers/observations.py
RENAMED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
from pyinaturalist.constants import HistogramResponse, IntOrStr, ListResponse
|
|
2
2
|
from pyinaturalist.controllers import BaseController
|
|
3
3
|
from pyinaturalist.docs import document_controller_params
|
|
4
|
-
from pyinaturalist.models import
|
|
4
|
+
from pyinaturalist.models import (
|
|
5
|
+
ControlledTermCounts,
|
|
6
|
+
LifeList,
|
|
7
|
+
Observation,
|
|
8
|
+
TaxonCounts,
|
|
9
|
+
TaxonSummary,
|
|
10
|
+
UserCounts,
|
|
11
|
+
)
|
|
5
12
|
from pyinaturalist.paginator import Paginator
|
|
6
13
|
from pyinaturalist.v1 import (
|
|
7
14
|
create_observation,
|
|
@@ -9,6 +16,7 @@ from pyinaturalist.v1 import (
|
|
|
9
16
|
get_observation_histogram,
|
|
10
17
|
get_observation_identifiers,
|
|
11
18
|
get_observation_observers,
|
|
19
|
+
get_observation_popular_field_values,
|
|
12
20
|
get_observation_species_counts,
|
|
13
21
|
get_observation_taxon_summary,
|
|
14
22
|
get_observation_taxonomy,
|
|
@@ -31,7 +39,7 @@ class ObservationController(BaseController):
|
|
|
31
39
|
|
|
32
40
|
@document_controller_params(get_observations)
|
|
33
41
|
def search(self, **params) -> Paginator[Observation]:
|
|
34
|
-
return self.client.paginate(get_observations, Observation, **params)
|
|
42
|
+
return self.client.paginate(get_observations, Observation, method='id', **params)
|
|
35
43
|
|
|
36
44
|
# TODO: Does this need a model with utility functions, or is {datetime: count} sufficient?
|
|
37
45
|
@document_controller_params(get_observation_histogram)
|
|
@@ -43,15 +51,20 @@ class ObservationController(BaseController):
|
|
|
43
51
|
response = self.client.request(get_observation_identifiers, **params)
|
|
44
52
|
return UserCounts.from_json(response)
|
|
45
53
|
|
|
54
|
+
@document_controller_params(get_observation_taxonomy, add_common_args=False)
|
|
55
|
+
def life_list(self, user_id: IntOrStr, **params) -> LifeList:
|
|
56
|
+
response = self.client.request(get_observation_taxonomy, user_id=user_id, **params)
|
|
57
|
+
return LifeList.from_json(response)
|
|
58
|
+
|
|
46
59
|
@document_controller_params(get_observation_observers)
|
|
47
60
|
def observers(self, **params) -> UserCounts:
|
|
48
61
|
response = self.client.request(get_observation_observers, **params)
|
|
49
62
|
return UserCounts.from_json(response)
|
|
50
63
|
|
|
51
|
-
@document_controller_params(
|
|
52
|
-
def
|
|
53
|
-
response = self.client.request(
|
|
54
|
-
return
|
|
64
|
+
@document_controller_params(get_observation_popular_field_values)
|
|
65
|
+
def popular_fields(self, **params) -> ControlledTermCounts:
|
|
66
|
+
response = self.client.request(get_observation_popular_field_values, **params)
|
|
67
|
+
return ControlledTermCounts.from_json(response)
|
|
55
68
|
|
|
56
69
|
@document_controller_params(get_observation_species_counts)
|
|
57
70
|
def species_counts(self, **params) -> TaxonCounts:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from pyinaturalist.constants import IntOrStr
|
|
2
|
+
from pyinaturalist.controllers import BaseController
|
|
3
|
+
from pyinaturalist.docs import document_controller_params
|
|
4
|
+
from pyinaturalist.models import Place
|
|
5
|
+
from pyinaturalist.paginator import AutocompletePaginator, Paginator
|
|
6
|
+
from pyinaturalist.v1 import get_places_autocomplete, get_places_by_id, get_places_nearby
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PlaceController(BaseController):
|
|
10
|
+
""":fa:`map-marker-alt,style=fas` Controller for Place requests"""
|
|
11
|
+
|
|
12
|
+
def from_id(self, *place_ids: IntOrStr, **params) -> Paginator[Place]:
|
|
13
|
+
"""Get places by ID
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
place_ids: One or more place IDs
|
|
17
|
+
"""
|
|
18
|
+
return self.client.paginate(get_places_by_id, Place, place_id=place_ids, **params)
|
|
19
|
+
|
|
20
|
+
@document_controller_params(get_places_autocomplete)
|
|
21
|
+
def autocomplete(self, q: str = None, **params) -> Paginator[Place]:
|
|
22
|
+
return self.client.paginate(
|
|
23
|
+
get_places_autocomplete,
|
|
24
|
+
Place,
|
|
25
|
+
cls=AutocompletePaginator,
|
|
26
|
+
q=q,
|
|
27
|
+
per_page=20,
|
|
28
|
+
**params,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
@document_controller_params(get_places_nearby)
|
|
32
|
+
def nearby(
|
|
33
|
+
self, nelat: float, nelng: float, swlat: float, swlng: float, **params
|
|
34
|
+
) -> Paginator[Place]:
|
|
35
|
+
return self.client.paginate(
|
|
36
|
+
get_places_nearby, Place, nelat=nelat, nelng=nelng, swlat=swlat, swlng=swlng, **params
|
|
37
|
+
)
|
|
@@ -3,7 +3,14 @@ from pyinaturalist.controllers import BaseController
|
|
|
3
3
|
from pyinaturalist.docs import document_controller_params
|
|
4
4
|
from pyinaturalist.models import Project
|
|
5
5
|
from pyinaturalist.paginator import Paginator
|
|
6
|
-
from pyinaturalist.v1 import
|
|
6
|
+
from pyinaturalist.v1 import (
|
|
7
|
+
add_project_observation,
|
|
8
|
+
add_project_users,
|
|
9
|
+
delete_project_users,
|
|
10
|
+
get_projects,
|
|
11
|
+
get_projects_by_id,
|
|
12
|
+
update_project,
|
|
13
|
+
)
|
|
7
14
|
|
|
8
15
|
|
|
9
16
|
class ProjectController(BaseController):
|
|
@@ -40,4 +47,17 @@ class ProjectController(BaseController):
|
|
|
40
47
|
responses.append(response)
|
|
41
48
|
return responses
|
|
42
49
|
|
|
43
|
-
|
|
50
|
+
@document_controller_params(update_project)
|
|
51
|
+
def update(self, project_id: IntOrStr, **params) -> Project:
|
|
52
|
+
response = self.client.request(update_project, project_id, **params)
|
|
53
|
+
return Project.from_json(response)
|
|
54
|
+
|
|
55
|
+
@document_controller_params(add_project_users)
|
|
56
|
+
def add_users(self, project_id: IntOrStr, *user_ids: int, **params) -> Project:
|
|
57
|
+
response = self.client.request(add_project_users, project_id, user_ids, **params)
|
|
58
|
+
return Project.from_json(response)
|
|
59
|
+
|
|
60
|
+
@document_controller_params(delete_project_users)
|
|
61
|
+
def delete_users(self, project_id: IntOrStr, *user_ids: int, **params) -> Project:
|
|
62
|
+
response = self.client.request(delete_project_users, project_id, user_ids, **params)
|
|
63
|
+
return Project.from_json(response)
|
|
@@ -71,17 +71,19 @@ def convert_all_timestamps(results: List[ResponseResult]) -> List[ResponseResult
|
|
|
71
71
|
return results
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
def
|
|
74
|
+
def convert_observation_histogram(response: JsonResponse) -> HistogramResponse:
|
|
75
75
|
"""Convert a response containing time series data into a single ``{date: value}`` dict"""
|
|
76
76
|
# The inner result object's key will be the name of the interval requested
|
|
77
77
|
interval = next(iter(response['results'].keys()))
|
|
78
|
-
|
|
78
|
+
return convert_histogram(response['results'][interval], interval)
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
def convert_histogram(result: JsonResponse, interval: str):
|
|
82
|
+
"""Convert keys to appropriate type depending on interval"""
|
|
81
83
|
if interval in ['month_of_year', 'week_of_year']:
|
|
82
|
-
return {int(k): v for k, v in
|
|
84
|
+
return {int(k): v for k, v in result.items()}
|
|
83
85
|
else:
|
|
84
|
-
return {parse_date(k): v for k, v in
|
|
86
|
+
return {parse_date(k): v for k, v in result.items()}
|
|
85
87
|
|
|
86
88
|
|
|
87
89
|
# Type conversion functions for individual results or values
|
|
@@ -202,6 +202,7 @@ def _observation_v1(
|
|
|
202
202
|
without_term_value_id: MultiInt = None,
|
|
203
203
|
acc_above: str = None,
|
|
204
204
|
acc_below: str = None,
|
|
205
|
+
acc_below_or_unknown: str = None,
|
|
205
206
|
created_d1: AnyDateTime = None,
|
|
206
207
|
created_d2: AnyDateTime = None,
|
|
207
208
|
created_on: AnyDate = None,
|
|
@@ -271,6 +272,7 @@ def _observation_v1(
|
|
|
271
272
|
Must be combined with the ``term_id`` parameter
|
|
272
273
|
acc_above: Must have an positional accuracy above this value (meters)
|
|
273
274
|
acc_below: Must have an positional accuracy below this value (meters)
|
|
275
|
+
acc_below_or_unknown: Must have an positional accuracy below this value (meters) or unknown
|
|
274
276
|
created_d1: Must be created at or after this time
|
|
275
277
|
created_d2: Must be created at or before this time
|
|
276
278
|
created_on: Must be created on this date
|
|
@@ -9,13 +9,12 @@ These functions will accept any of the following:
|
|
|
9
9
|
"""
|
|
10
10
|
import json
|
|
11
11
|
from copy import deepcopy
|
|
12
|
-
from datetime import date, datetime
|
|
12
|
+
from datetime import date, datetime, timedelta
|
|
13
13
|
from functools import partial
|
|
14
14
|
from logging import basicConfig, getLogger
|
|
15
|
-
from typing import
|
|
15
|
+
from typing import List, Mapping, Type
|
|
16
16
|
|
|
17
|
-
from
|
|
18
|
-
from requests import PreparedRequest
|
|
17
|
+
from requests import PreparedRequest, Response
|
|
19
18
|
|
|
20
19
|
from pyinaturalist.constants import DATETIME_SHORT_FORMAT, ResponseOrResults, ResponseResult
|
|
21
20
|
from pyinaturalist.converters import ensure_list
|
|
@@ -25,6 +24,7 @@ from pyinaturalist.models import (
|
|
|
25
24
|
BaseModelCollection,
|
|
26
25
|
Comment,
|
|
27
26
|
ControlledTerm,
|
|
27
|
+
ControlledTermCount,
|
|
28
28
|
ControlledTermValue,
|
|
29
29
|
Identification,
|
|
30
30
|
LifeList,
|
|
@@ -42,15 +42,16 @@ from pyinaturalist.models import (
|
|
|
42
42
|
TaxonCount,
|
|
43
43
|
TaxonSummary,
|
|
44
44
|
User,
|
|
45
|
-
get_lazy_attrs,
|
|
46
45
|
)
|
|
47
46
|
from pyinaturalist.paginator import Paginator
|
|
48
47
|
|
|
49
48
|
|
|
50
49
|
def enable_logging(level: str = 'INFO'):
|
|
51
|
-
"""Configure logging to standard output with prettier tracebacks and terminal
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
"""Configure logging to standard output with prettier tracebacks, formatting, and terminal
|
|
51
|
+
colors (if supported).
|
|
52
|
+
|
|
53
|
+
If you prefer, logging can be configured with the stdlib ``logging`` module instead; this just
|
|
54
|
+
provides some convenient defaults.
|
|
54
55
|
|
|
55
56
|
Args:
|
|
56
57
|
level: Logging level to use
|
|
@@ -115,6 +116,7 @@ UNIQUE_RESPONSE_ATTRS = {
|
|
|
115
116
|
'thread_id': Message,
|
|
116
117
|
'body': Comment, # Subset of ID attrs; if it's not an ID, assume it's a comment
|
|
117
118
|
'multivalued': ControlledTerm,
|
|
119
|
+
'controlled_value': ControlledTermCount,
|
|
118
120
|
'blocking': ControlledTermValue,
|
|
119
121
|
'count_without_taxon': LifeList,
|
|
120
122
|
'captive': Observation,
|
|
@@ -200,14 +202,41 @@ def format_table(values: ResponseOrObjects):
|
|
|
200
202
|
|
|
201
203
|
def format_request(request: PreparedRequest, dry_run: bool = False) -> str:
|
|
202
204
|
"""Format HTTP request info"""
|
|
203
|
-
|
|
205
|
+
headers = _format_headers(request.headers)
|
|
206
|
+
body = _format_body(request.body)
|
|
207
|
+
dry_run_str = ' (DRY RUN) ' if dry_run else ''
|
|
208
|
+
return f'Request:{dry_run_str}\n{request.method} {request.url}\n{headers}\n{body}'
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def format_response(response: Response) -> str:
|
|
212
|
+
"""Format HTTP response info, including whether it came from the cache"""
|
|
213
|
+
headers = _format_headers(response.headers)
|
|
214
|
+
error_msg = f' {response.text}' if not response.ok else ''
|
|
215
|
+
|
|
216
|
+
def _expires_str():
|
|
217
|
+
if response.expires:
|
|
218
|
+
expires_delta = response.expires - datetime.utcnow()
|
|
219
|
+
expires_delta -= timedelta(microseconds=expires_delta.microseconds)
|
|
220
|
+
return f'expires in {expires_delta}'
|
|
221
|
+
else:
|
|
222
|
+
return 'never expires'
|
|
223
|
+
|
|
224
|
+
cached = f'cached; {_expires_str()}' if getattr(response, 'from_cache', False) else 'not cached'
|
|
225
|
+
return f'Response ({cached}):\n{response.status_code} {response.reason}{error_msg}\n{headers}'
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _format_headers(headers: Mapping[str, str]) -> str:
|
|
229
|
+
ignore_headers = [
|
|
230
|
+
'Access-Control-Allow-Headers',
|
|
231
|
+
'Access-Control-Allow-Methods',
|
|
232
|
+
'Access-Control-Allow-Origin',
|
|
233
|
+
'X-Content-Type-Options',
|
|
234
|
+
]
|
|
235
|
+
headers_dict = {k: v for k, v in headers.items() if k not in ignore_headers}
|
|
204
236
|
if 'Authorization' in headers_dict:
|
|
205
237
|
headers_dict['Authorization'] = '[REDACTED]'
|
|
206
238
|
|
|
207
|
-
|
|
208
|
-
body = _format_body(request.body)
|
|
209
|
-
dry_run_str = '(DRY RUN) ' if dry_run else ''
|
|
210
|
-
return f'{dry_run_str}{request.method} {request.url}\n{headers}\n{body}'
|
|
239
|
+
return '\n'.join([f'{k}: {v}' for k, v in headers_dict.items()])
|
|
211
240
|
|
|
212
241
|
|
|
213
242
|
def _format_body(body):
|
|
@@ -271,36 +300,10 @@ format_species_counts = partial(_format_model_objects, cls=TaxonCount)
|
|
|
271
300
|
format_taxa = partial(_format_model_objects, cls=Taxon)
|
|
272
301
|
format_users = partial(_format_model_objects, cls=User)
|
|
273
302
|
|
|
274
|
-
|
|
275
|
-
def get_model_fields(obj: Any) -> Iterable[Attribute]:
|
|
276
|
-
"""Modification for rich's pretty-printer (specifically, ``rich.pretty._get_attr_fields``).
|
|
277
|
-
|
|
278
|
-
Adds placeholder attributes for lazy-loaded model properties so they get included in the output.
|
|
279
|
-
This is particularly useful for previewing in Jupyter or another REPL. These nested objects are
|
|
280
|
-
shown in condensed format so the preview is more readable. Otherwise, some objects]
|
|
281
|
-
(especially observations) can turn into a huge wall of text several pages long.
|
|
282
|
-
|
|
283
|
-
Does not change behavior for anything except :py:class:`.BaseModel` subclasses.
|
|
284
|
-
"""
|
|
285
|
-
|
|
286
|
-
def condense_nested_models(obj):
|
|
287
|
-
tab = ' '
|
|
288
|
-
if obj and isinstance(obj, list):
|
|
289
|
-
condensed_objs = f',\n{tab}{tab}'.join([str(o) for o in obj])
|
|
290
|
-
return f'[\n{tab}{tab}{condensed_objs}\n{tab}]'
|
|
291
|
-
return str(obj)
|
|
292
|
-
|
|
293
|
-
attrs = list(obj.__attrs_attrs__)
|
|
294
|
-
if isinstance(obj, BaseModel):
|
|
295
|
-
attrs += get_lazy_attrs(obj, repr=condense_nested_models)
|
|
296
|
-
return attrs
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
# If rich is installed, update its pretty-printer to include model properties
|
|
303
|
+
# If rich is installed, install pretty-printer
|
|
300
304
|
try:
|
|
301
305
|
from rich import pretty, print
|
|
302
306
|
|
|
303
|
-
pretty._get_attr_fields = get_model_fields
|
|
304
307
|
pretty.install()
|
|
305
308
|
except ImportError:
|
|
306
309
|
pass
|