From 2723079fce5a677ae068568018900c391b1a1f69 Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Mon, 9 May 2022 14:54:46 -0600 Subject: [PATCH 01/16] chore: Synced file(s) with googlemaps/.github (#432) * chore: Created local '.github/CODEOWNERS' from remote '.github/CODEOWNERS' * chore: Created local '.github/sync-repo-settings.yaml' from remote '.github/sync-repo-settings.yaml' --- .github/CODEOWNERS | 17 +++++++++++++++ .github/sync-repo-settings.yaml | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/sync-repo-settings.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..e95e611e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +.github/ @googlemaps/admin diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml new file mode 100644 index 00000000..84693ce8 --- /dev/null +++ b/.github/sync-repo-settings.yaml @@ -0,0 +1,38 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings + +rebaseMergeAllowed: true +squashMergeAllowed: true +mergeCommitAllowed: false +deleteBranchOnMerge: true +branchProtectionRules: +- pattern: main + isAdminEnforced: false + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - 'cla/google' + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true +- pattern: master + isAdminEnforced: false + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - 'cla/google' + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true +permissionRules: + - team: admin + permission: admin From 628ab311f8416a2b49a4acbccb8d27747bf0a4a5 Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Mon, 9 May 2022 15:36:13 -0600 Subject: [PATCH 02/16] chore: Synced local '.github/sync-repo-settings.yaml' with remote '.github/sync-repo-settings.yaml' (#433) --- .github/sync-repo-settings.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 84693ce8..98d0b463 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -24,6 +24,7 @@ branchProtectionRules: requiresStrictStatusChecks: false requiredStatusCheckContexts: - 'cla/google' + - 'test' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true - pattern: master @@ -31,6 +32,7 @@ branchProtectionRules: requiresStrictStatusChecks: false requiredStatusCheckContexts: - 'cla/google' + - 'test' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true permissionRules: From e710ba7b5aeb9156b5112dbd55bd71903128f8c4 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 12:15:23 -0600 Subject: [PATCH 03/16] build: update required checks (#435) --- .github/sync-repo-settings.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 98d0b463..746f8e52 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -25,6 +25,8 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' + - 'snippet-bot-check' + - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true - pattern: master @@ -33,6 +35,8 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' + - 'snippet-bot-check' + - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true permissionRules: From c67d453305fb103aa6ccc3639cf1733854ea480b Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 12:47:51 -0600 Subject: [PATCH 04/16] chore: fix typo in check name (#436) --- .github/sync-repo-settings.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 746f8e52..a7b2d39c 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -25,7 +25,7 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' - - 'snippet-bot-check' + - 'snippet-bot check' - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true @@ -35,7 +35,7 @@ branchProtectionRules: requiredStatusCheckContexts: - 'cla/google' - 'test' - - 'snippet-bot-check' + - 'snippet-bot check' - 'header-check' requiredApprovingReviewCount: 1 requiresCodeOwnerReviews: true From 1d995b4420ab369d8c23fcdef8b55e284f80dde0 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 14:06:01 -0600 Subject: [PATCH 05/16] build: update workflow and standardize check name --- .github/workflows/test.yml | 8 +++++++- README.md | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8123e23..ddcc2e6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ on: branches: ['*'] jobs: - test: + matrix: name: "Run tests on Python ${{ matrix.python-version }}" runs-on: ubuntu-latest strategy: @@ -46,3 +46,9 @@ jobs: run: | python3 -m nox --session "tests-${{ matrix.python-version }}" python3 -m nox -e distribution + test: + name: Wait for matrix to finish + needs: [matrix] + runs-on: ubuntu-latest + steps: + - run: echo "Test matrix finished" diff --git a/README.md b/README.md index 31840082..21564486 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ Python Client for Google Maps Services ==================================== -[![Build Status](https://travis-ci.org/googlemaps/google-maps-services-python.svg?branch=master)](https://travis-ci.org/googlemaps/google-maps-services-python) +![Test](https://github.com/googlemaps/google-maps-services-js/workflows/test/badge.svg) +![Release](https://github.com/googlemaps/google-maps-services-js/workflows/release/badge.svg) [![codecov](https://codecov.io/gh/googlemaps/google-maps-services-python/branch/master/graph/badge.svg)](https://codecov.io/gh/googlemaps/google-maps-services-python) [![PyPI version](https://badge.fury.io/py/googlemaps.svg)](https://badge.fury.io/py/googlemaps) ![PyPI - Downloads](https://img.shields.io/pypi/dd/googlemaps) From f59f66b81326f8f2b9aeadd41df8bba4ac58ff9b Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Tue, 10 May 2022 14:34:42 -0600 Subject: [PATCH 06/16] docs: fix badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21564486..54c024b3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Python Client for Google Maps Services ==================================== -![Test](https://github.com/googlemaps/google-maps-services-js/workflows/test/badge.svg) -![Release](https://github.com/googlemaps/google-maps-services-js/workflows/release/badge.svg) +![Test](https://github.com/googlemaps/google-maps-services-js/workflows/Test/badge.svg) +![Release](https://github.com/googlemaps/google-maps-services-js/workflows/Release/badge.svg) [![codecov](https://codecov.io/gh/googlemaps/google-maps-services-python/branch/master/graph/badge.svg)](https://codecov.io/gh/googlemaps/google-maps-services-python) [![PyPI version](https://badge.fury.io/py/googlemaps.svg)](https://badge.fury.io/py/googlemaps) ![PyPI - Downloads](https://img.shields.io/pypi/dd/googlemaps) From dfa5e7f2e5f5a0371f607b07538b6c084d8c5b42 Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Tue, 10 May 2022 15:31:35 -0600 Subject: [PATCH 07/16] chore: Created local '.github/workflows/dependabot.yml' from remote '.github/workflows/dependabot.yml' (#434) --- .github/workflows/dependabot.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/dependabot.yml diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 00000000..597e7636 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,36 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Dependabot +on: pull_request + +permissions: + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} + steps: + - name: approve + run: gh pr review --comment -b "Automatically approved since dependabot is [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `automatic`." + if: ${{ github.event.label.name == 'automatic' }} + - name: approve-instructions + run: echo "configure dependabot with label 'automatic' to have it automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" + if: ${{ github.event.label.name != 'automatic' }} + - name: merge + run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 381563b0ea97d28beb1a0a54299549536fe6ce9c Mon Sep 17 00:00:00 2001 From: googlemaps-bot Date: Wed, 11 May 2022 15:35:06 -0600 Subject: [PATCH 08/16] chore: Synced local '.github/workflows/dependabot.yml' with remote '.github/workflows/dependabot.yml' (#437) --- .github/workflows/dependabot.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 597e7636..12013710 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,10 +27,10 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved since dependabot is [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `automatic`." - if: ${{ github.event.label.name == 'automatic' }} + run: gh pr review --comment -b "Automatically approved since dependabot is not [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `do not merge`." + if: ${{ github.event.label.name != 'do not merge' }} - name: approve-instructions - run: echo "configure dependabot with label 'automatic' to have it automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" - if: ${{ github.event.label.name != 'automatic' }} + run: echo "Configure dependabot with label 'do not merge' to prevent it from being automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" + if: ${{ github.event.label.name == 'do not merge' }} - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 8d334a87946442e6d786f9eb0a80a5840eb3cd72 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 09:49:55 -0600 Subject: [PATCH 09/16] chore: simplify dependabot workflow --- .github/workflows/dependabot.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 12013710..c4c66544 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -28,9 +28,5 @@ jobs: steps: - name: approve run: gh pr review --comment -b "Automatically approved since dependabot is not [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `do not merge`." - if: ${{ github.event.label.name != 'do not merge' }} - - name: approve-instructions - run: echo "Configure dependabot with label 'do not merge' to prevent it from being automatically approved and merged. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels" - if: ${{ github.event.label.name == 'do not merge' }} - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From fd2933fc8c23e9caa3bb4a5bc74ae0692babde05 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 09:52:52 -0600 Subject: [PATCH 10/16] chore: update pull request approval comment --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index c4c66544..b9853abf 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved since dependabot is not [configured](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#labels) with label `do not merge`." + run: gh pr review --comment -b "Automatically approved dependabot pull request." - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 407e81be1ded5026752c1412f0c8330ca0caa6bd Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 09:59:57 -0600 Subject: [PATCH 11/16] chore: fix approval by providing url to pr --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index b9853abf..aacd8097 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved dependabot pull request." + run: gh pr review --comment -b "Automatically approved dependabot pull request." "$PR_URL" - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 7548bb2487d17e93149c40015c9e8b76576180e3 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 10:09:50 -0600 Subject: [PATCH 12/16] chore: add --approve --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index aacd8097..904a1990 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --comment -b "Automatically approved dependabot pull request." "$PR_URL" + run: gh pr review --approve --comment -b "Automatically approved dependabot pull request." "$PR_URL" - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 62e1a306059296b7fb9034b709253e2ed6c6ca9c Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 12 May 2022 10:21:04 -0600 Subject: [PATCH 13/16] chore: only approve --- .github/workflows/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 904a1990..6b46ebbb 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -27,6 +27,6 @@ jobs: GITHUB_TOKEN: ${{secrets.SYNCED_GITHUB_TOKEN_REPO}} steps: - name: approve - run: gh pr review --approve --comment -b "Automatically approved dependabot pull request." "$PR_URL" + run: gh pr review --approve "$PR_URL" - name: merge run: gh pr merge --auto --squash --delete-branch "$PR_URL" From 8f7209439db457c38da2ea1b6e9115cb727ee39d Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Thu, 19 May 2022 13:24:17 -0600 Subject: [PATCH 14/16] build: change dependabot interval to weekly (#439) --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 491deae0..55a9ccdd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,5 +3,5 @@ updates: - package-ecosystem: pip directory: "/" schedule: - interval: daily + interval: "weekly" open-pull-requests-limit: 10 From 3bcb05f56ec0745d9ecaac677c31963cac8ece18 Mon Sep 17 00:00:00 2001 From: anglarett Date: Wed, 9 Nov 2022 17:19:51 +0100 Subject: [PATCH 15/16] feat: Adds support for Address Validation API (#448) --- .github/dependabot.yml | 14 + .github/scripts/distribution.sh | 14 + .github/scripts/install.sh | 14 + .github/stale.yml | 14 + .gitignore | 2 + README.md | 7 + coverage.xml | 849 ++++++++++++++++++++++++++++++++ docs/conf.py | 14 + googlemaps/addressvalidation.py | 80 +++ googlemaps/client.py | 36 +- noxfile.py | 14 + setup.py | 14 + tests/test_addressvalidation.py | 48 ++ text.py | 19 + 14 files changed, 1133 insertions(+), 6 deletions(-) create mode 100644 coverage.xml create mode 100644 googlemaps/addressvalidation.py create mode 100644 tests/test_addressvalidation.py create mode 100644 text.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 55a9ccdd..36f9436b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + version: 2 updates: - package-ecosystem: pip diff --git a/.github/scripts/distribution.sh b/.github/scripts/distribution.sh index f7c08690..e779cd1d 100755 --- a/.github/scripts/distribution.sh +++ b/.github/scripts/distribution.sh @@ -1,4 +1,18 @@ #!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + rm -rf dist diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh index a585594c..39e7f9f0 100755 --- a/.github/scripts/install.sh +++ b/.github/scripts/install.sh @@ -1,4 +1,18 @@ #!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -exo pipefail diff --git a/.github/stale.yml b/.github/stale.yml index 8ed0e080..1d39e65d 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Configuration for probot-stale - https://github.com/probot/stale # Number of days of inactivity before an Issue or Pull Request becomes stale diff --git a/.gitignore b/.gitignore index c4477ba5..74d89080 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ googlemaps.egg-info *.egg .vscode/ .idea/ +index.py +test.py diff --git a/README.md b/README.md index 54c024b3..cb5f7821 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ APIs: - Roads API - Places API - Maps Static API + - Address Validation API Keep in mind that the same [terms and conditions](https://developers.google.com/maps/terms) apply to usage of the APIs when they're accessed through this library. @@ -85,6 +86,12 @@ directions_result = gmaps.directions("Sydney Town Hall", "Parramatta, NSW", mode="transit", departure_time=now) + +# Validate an address with address validation +addressvalidation_result = gmaps.addressvalidation(['1600 Amphitheatre Pk'], + regionCode='US', + locality='Mountain View', + enableUspsCass=True) ``` For more usage examples, check out [the tests](https://github.com/googlemaps/google-maps-services-python/tree/master/tests). diff --git a/coverage.xml b/coverage.xml new file mode 100644 index 00000000..1c38ca3d --- /dev/null +++ b/coverage.xml @@ -0,0 +1,849 @@ + + + + + + /Users/anglarett/Public/Drop Box/dev-se-git/google-maps-services-python + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/conf.py b/docs/conf.py index 19cdfef5..0d8314fb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # -*- coding: utf-8 -*- # # Maps API documentation build configuration file, created by diff --git a/googlemaps/addressvalidation.py b/googlemaps/addressvalidation.py new file mode 100644 index 00000000..45b74655 --- /dev/null +++ b/googlemaps/addressvalidation.py @@ -0,0 +1,80 @@ +# +# Copyright 2014 Google Inc. All rights reserved. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# + +"""Performs requests to the Google Maps Address Validation API.""" +from googlemaps import exceptions + + +_ADDRESSVALIDATION_BASE_URL = "https://addressvalidation.googleapis.com" + + +def _addressvalidation_extract(response): + """ + Mimics the exception handling logic in ``client._get_body``, but + for addressvalidation which uses a different response format. + """ + body = response.json() + return body + + # if response.status_code in (200, 404): + # return body + + # try: + # error = body["error"]["errors"][0]["reason"] + # except KeyError: + # error = None + + # if response.status_code == 403: + # raise exceptions._OverQueryLimit(response.status_code, error) + # else: + # raise exceptions.ApiError(response.status_code, error) + + +def addressvalidation(client, addressLines, regionCode=None , locality=None, enableUspsCass=None): + """ + The Google Maps Address Validation API returns a verification of an address + See https://developers.google.com/maps/documentation/address-validation/overview + request must include parameters below. + :param addressLines: The address to validate + :type addressLines: array + :param regionCode: (optional) The country code + :type regionCode: string + :param locality: (optional) Restrict to a locality, ie:Mountain View + :type locality: string + :param enableUspsCass For the "US" and "PR" regions only, you can optionally enable the Coding Accuracy Support System (CASS) from the United States Postal Service (USPS) + :type locality: boolean + """ + + params = { + "address":{ + "addressLines": addressLines + } + } + + if regionCode is not None: + params["address"]["regionCode"] = regionCode + + if locality is not None: + params["address"]["locality"] = locality + + if enableUspsCass is not False or enableUspsCass is not None: + params["enableUspsCass"] = enableUspsCass + + return client._request("/v1:validateAddress", {}, # No GET params + base_url=_ADDRESSVALIDATION_BASE_URL, + extract_body=_addressvalidation_extract, + post_json=params) \ No newline at end of file diff --git a/googlemaps/client.py b/googlemaps/client.py index 1334571d..54838fa0 100644 --- a/googlemaps/client.py +++ b/googlemaps/client.py @@ -31,6 +31,8 @@ import requests import random import time +import math +import sys import googlemaps @@ -52,7 +54,7 @@ class Client: def __init__(self, key=None, client_id=None, client_secret=None, timeout=None, connect_timeout=None, read_timeout=None, retry_timeout=60, requests_kwargs=None, - queries_per_second=50, channel=None, + queries_per_second=60, queries_per_minute=6000,channel=None, retry_over_query_limit=True, experience_id=None, requests_session=None, base_url=_DEFAULT_BASE_URL): @@ -93,11 +95,16 @@ def __init__(self, key=None, client_id=None, client_secret=None, seconds. :type retry_timeout: int - :param queries_per_second: Number of queries per second permitted. + :param queries_per_second: Number of queries per second permitted. Unset queries_per_minute to None. If set smaller number will be used. If the rate limit is reached, the client will sleep for the appropriate amount of time before it runs the current query. :type queries_per_second: int + :param queries_per_minute: Number of queries per minute permitted. Unset queries_per_second to None. If set smaller number will be used. + If the rate limit is reached, the client will sleep for the + appropriate amount of time before it runs the current query. + :type queries_per_minute: int + :param retry_over_query_limit: If True, requests that result in a response indicating the query rate limit was exceeded will be retried. Defaults to True. @@ -169,10 +176,26 @@ def __init__(self, key=None, client_id=None, client_secret=None, "timeout": self.timeout, "verify": True, # NOTE(cbro): verify SSL certs. }) - + + self.queries_quota : int self.queries_per_second = queries_per_second + self.queries_per_minute = queries_per_minute + try: + if (type(self.queries_per_second) == int and type(self.queries_per_minute) == int ): + self.queries_quota = math.floor(min(self.queries_per_second, self.queries_per_minute/60)) + elif (self.queries_per_second and type(self.queries_per_second) == int ): + self.queries_quota = math.floor(self.queries_per_second) + elif (self.queries_per_minute and type(self.queries_per_minute) == int ): + self.queries_quota = math.floor(self.queries_per_minute/60) + else: + sys.exit("MISSING VALID NUMBER for queries_per_second or queries_per_minute") + print("\n","API queries_quota:", self.queries_quota,"\n") + + except NameError: + sys.exit("MISSING VALUE for queries_per_second or queries_per_minute") + self.retry_over_query_limit = retry_over_query_limit - self.sent_times = collections.deque("", queries_per_second) + self.sent_times = collections.deque("", self.queries_quota) self.set_experience_id(experience_id) self.base_url = base_url @@ -303,7 +326,7 @@ def _request(self, url, params, first_request_time=None, retry_counter=0, # Check if the time of the nth previous query (where n is # queries_per_second) is under a second ago - if so, sleep for # the difference. - if self.sent_times and len(self.sent_times) == self.queries_per_second: + if self.sent_times and len(self.sent_times) == self.queries_quota: elapsed_since_earliest = time.time() - self.sent_times[0] if elapsed_since_earliest < 1: time.sleep(1 - elapsed_since_earliest) @@ -402,7 +425,7 @@ def _generate_auth_url(self, path, params, accepts_clientid): from googlemaps.places import places_autocomplete from googlemaps.places import places_autocomplete_query from googlemaps.maps import static_map - +from googlemaps.addressvalidation import addressvalidation def make_api_method(func): """ @@ -446,6 +469,7 @@ def wrapper(*args, **kwargs): Client.places_autocomplete = make_api_method(places_autocomplete) Client.places_autocomplete_query = make_api_method(places_autocomplete_query) Client.static_map = make_api_method(static_map) +Client.addressvalidation = make_api_method(addressvalidation) def sign_hmac(secret, payload): diff --git a/noxfile.py b/noxfile.py index d3357fe4..2bc3b2a1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import nox SUPPORTED_PY_VERSIONS = ["3.7", "3.8", "3.9", "3.10"] diff --git a/setup.py b/setup.py index 8826822d..b2536fc3 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,17 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from setuptools import setup diff --git a/tests/test_addressvalidation.py b/tests/test_addressvalidation.py new file mode 100644 index 00000000..69ad8b70 --- /dev/null +++ b/tests/test_addressvalidation.py @@ -0,0 +1,48 @@ +# This Python file uses the following encoding: utf-8 +# +# Copyright 2017 Google Inc. All rights reserved. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# + +"""Tests for the addressvalidation module.""" + +import responses + +import googlemaps +from . import TestCase + + +class AddressValidationTest(TestCase): + def setUp(self): + self.key = "AIzaasdf" + self.client = googlemaps.Client(self.key) + + @responses.activate + def test_simple_addressvalidation(self): + responses.add( + responses.POST, + "https://addressvalidation.googleapis.com/v1:validateAddress", + body='{"address": {"regionCode": "US","locality": "Mountain View","addressLines": "1600 Amphitheatre Pkwy"},"enableUspsCass":true}', + status=200, + content_type="application/json", + ) + + results = self.client.addressvalidation('1600 Amphitheatre Pk', regionCode='US', locality='Mountain View', enableUspsCass=True) + + self.assertEqual(1, len(responses.calls)) + self.assertURLEqual( + "https://addressvalidation.googleapis.com/v1:validateAddress?" "key=%s" % self.key, + responses.calls[0].request.url, + ) \ No newline at end of file diff --git a/text.py b/text.py new file mode 100644 index 00000000..13734488 --- /dev/null +++ b/text.py @@ -0,0 +1,19 @@ +import math + +queries_quota : int +queries_per_second = 60 # None or 60 +queries_per_minute = None # None or 6000 + +try: + if (type(queries_per_second) == int and type(queries_per_minute) == int ): + queries_quota = math.floor(min(queries_per_second, queries_per_minute/60)) + elif (queries_per_second): + queries_quota = math.floor(queries_per_second) + elif (queries_per_minute): + queries_quota = math.floor(queries_per_minute/60) + else: + print("MISSING VALID NUMBER for queries_per_second or queries_per_minute") + print(queries_quota) + +except NameError: + print("MISSING VALUE for queries_per_second or queries_per_minute") \ No newline at end of file From 6d7a993d49c090c3e06fd1e3bf3019d184279b47 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 9 Nov 2022 16:20:57 +0000 Subject: [PATCH 16/16] chore(release): 4.7.0 [skip ci] # [4.7.0](https://github.com/googlemaps/google-maps-services-python/compare/v4.6.0...v4.7.0) (2022-11-09) ### Features * Adds support for Address Validation API ([#448](https://github.com/googlemaps/google-maps-services-python/issues/448)) ([3bcb05f](https://github.com/googlemaps/google-maps-services-python/commit/3bcb05f56ec0745d9ecaac677c31963cac8ece18)) --- googlemaps/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemaps/__init__.py b/googlemaps/__init__.py index ffde203b..4a3b3b91 100644 --- a/googlemaps/__init__.py +++ b/googlemaps/__init__.py @@ -15,7 +15,7 @@ # the License. # -__version__ = "4.6.0" +__version__ = "4.7.0" from googlemaps.client import Client from googlemaps import exceptions diff --git a/setup.py b/setup.py index b2536fc3..51ccabf8 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="googlemaps", - version="4.6.0", + version="4.7.0", description="Python client library for Google Maps Platform", long_description=readme + changelog, long_description_content_type="text/markdown",