From 87a7595eaee4b9bcf06e959fa43fb808f7cb61b8 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Tue, 2 Jun 2020 15:51:41 -0700 Subject: [PATCH 1/5] Update geo_data to pick up a couple renames --- octodns/record/geo_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octodns/record/geo_data.py b/octodns/record/geo_data.py index 5393db0..051d446 100644 --- a/octodns/record/geo_data.py +++ b/octodns/record/geo_data.py @@ -55,7 +55,7 @@ geo_data = \ 'SO': {'name': 'Somalia'}, 'SS': {'name': 'South Sudan'}, 'ST': {'name': 'Sao Tome and Principe'}, - 'SZ': {'name': 'Swaziland'}, + 'SZ': {'name': 'Eswatini'}, 'TD': {'name': 'Chad'}, 'TG': {'name': 'Togo'}, 'TN': {'name': 'Tunisia'}, @@ -157,7 +157,7 @@ geo_data = \ 'MC': {'name': 'Monaco'}, 'MD': {'name': 'Moldova, Republic of'}, 'ME': {'name': 'Montenegro'}, - 'MK': {'name': 'Macedonia, Republic of'}, + 'MK': {'name': 'North Macedonia'}, 'MT': {'name': 'Malta'}, 'NL': {'name': 'Netherlands'}, 'NO': {'name': 'Norway'}, From 1569d94513758bbae628930ea05730bc8e8d4b13 Mon Sep 17 00:00:00 2001 From: Dan Hanks Date: Wed, 3 Jun 2020 09:36:33 -0400 Subject: [PATCH 2/5] Add support for geo-targeting of CA provinces - For providers that support such --- octodns/record/geo.py | 11 ++++++++--- script/generate-geo-data | 4 ++-- tests/test_octodns_record_geo.py | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/octodns/record/geo.py b/octodns/record/geo.py index ed54194..bd8ebc3 100644 --- a/octodns/record/geo.py +++ b/octodns/record/geo.py @@ -63,9 +63,14 @@ class GeoCodes(object): @classmethod def province_to_code(cls, province): - # We get to cheat on this one since we only support provinces in NA-US - if province not in geo_data['NA']['US']['provinces']: + # We cheat on this one a little since we only support provinces in NA-US, NA-CA + if (province not in geo_data['NA']['US']['provinces'] and + province not in geo_data['NA']['CA']['provinces']): cls.log.warn('country_to_code: unrecognized province "%s"', province) return - return 'NA-US-{}'.format(province) + if province in geo_data['NA']['US']['provinces']: + country = 'US' + if province in geo_data['NA']['CA']['provinces']: + country = 'CA' + return 'NA-{}-{}'.format(country, province) diff --git a/script/generate-geo-data b/script/generate-geo-data index 87a57b1..da49701 100755 --- a/script/generate-geo-data +++ b/script/generate-geo-data @@ -8,8 +8,8 @@ from pycountry_convert import country_alpha2_to_continent_code subs = defaultdict(dict) for subdivision in subdivisions: - # Route53 only supports US states, Dyn supports US states and CA provinces, but for now we'll just do US - if subdivision.country_code not in ('US'): + # Route53 only supports US states, Dyn (and others) support US states and CA provinces + if subdivision.country_code not in ('US', 'CA'): continue subs[subdivision.country_code][subdivision.code[3:]] = { 'name': subdivision.name diff --git a/tests/test_octodns_record_geo.py b/tests/test_octodns_record_geo.py index 5b7454c..35df6d5 100644 --- a/tests/test_octodns_record_geo.py +++ b/tests/test_octodns_record_geo.py @@ -77,4 +77,6 @@ class TestRecordGeoCodes(TestCase): def test_province_to_code(self): self.assertEquals('NA-US-OR', GeoCodes.province_to_code('OR')) self.assertEquals('NA-US-KY', GeoCodes.province_to_code('KY')) + self.assertEquals('NA-CA-AB', GeoCodes.province_to_code('AB')) + self.assertEquals('NA-CA-BC', GeoCodes.province_to_code('BC')) self.assertFalse(GeoCodes.province_to_code('XX')) From 559a3994e6339047db492c38de09bc9661755d5a Mon Sep 17 00:00:00 2001 From: Dan Hanks Date: Wed, 3 Jun 2020 10:07:35 -0400 Subject: [PATCH 3/5] Fix comment < 80 chars --- octodns/record/geo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/octodns/record/geo.py b/octodns/record/geo.py index bd8ebc3..0a2f1a3 100644 --- a/octodns/record/geo.py +++ b/octodns/record/geo.py @@ -63,7 +63,8 @@ class GeoCodes(object): @classmethod def province_to_code(cls, province): - # We cheat on this one a little since we only support provinces in NA-US, NA-CA + # We cheat on this one a little since we only support provinces in + # NA-US, NA-CA if (province not in geo_data['NA']['US']['provinces'] and province not in geo_data['NA']['CA']['provinces']): cls.log.warn('country_to_code: unrecognized province "%s"', From 07279e48047550f8587e1037f1438b4ae91bac91 Mon Sep 17 00:00:00 2001 From: Dan Hanks Date: Wed, 3 Jun 2020 11:10:54 -0400 Subject: [PATCH 4/5] Add Canadian provinces to geo_data.py --- octodns/record/geo_data.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/octodns/record/geo_data.py b/octodns/record/geo_data.py index 051d446..13b05e6 100644 --- a/octodns/record/geo_data.py +++ b/octodns/record/geo_data.py @@ -183,7 +183,20 @@ geo_data = \ 'BQ': {'name': 'Bonaire, Sint Eustatius and Saba'}, 'BS': {'name': 'Bahamas'}, 'BZ': {'name': 'Belize'}, - 'CA': {'name': 'Canada'}, + 'CA': {'name': 'Canada', + 'provinces': {'AB': {'name': 'Alberta'}, + 'BC': {'name': 'British Columbia'}, + 'MB': {'name': 'Manitoba'}, + 'NB': {'name': 'New Brunswick'}, + 'NL': {'name': 'Newfoundland and Labrador'}, + 'NS': {'name': 'Nova Scotia'}, + 'NT': {'name': 'Northwest Territories'}, + 'NU': {'name': 'Nunavut'}, + 'ON': {'name': 'Ontario'}, + 'PE': {'name': 'Prince Edward Island'}, + 'QC': {'name': 'Quebec'}, + 'SK': {'name': 'Saskatchewan'}, + 'YT': {'name': 'Yukon Territory'}}}, 'CR': {'name': 'Costa Rica'}, 'CU': {'name': 'Cuba'}, 'CW': {'name': 'CuraƧao'}, From 331b638c059b2295fff97eb90bfaa409f18b5692 Mon Sep 17 00:00:00 2001 From: Lance Hudson Date: Thu, 11 Jun 2020 20:07:41 -0400 Subject: [PATCH 5/5] Update contributing directions --- CONTRIBUTING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3a8f48..ea891ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,12 +11,13 @@ If you have questions, or you'd like to check with us before embarking on a majo This project uses the [GitHub Flow](https://guides.github.com/introduction/flow/). That means that the `master` branch is stable and new development is done in feature branches. Feature branches are merged into the `master` branch via a Pull Request. 0. Fork and clone the repository -0. Configure and install the dependencies: `script/bootstrap` -0. Make sure the tests pass on your machine: `script/test` +0. Configure and install the dependencies: `./script/bootstrap` +0. Activate virtual environment: `source env/bin/activate` +0. Make sure the tests pass on your machine: `./script/test` 0. Create a new branch: `git checkout -b my-branch-name` 0. Make your change, add tests, and make sure the tests still pass 0. Make sure that `./script/lint` passes without any warnings -0. Make sure that coverage is at :100:% `script/coverage` and open `htmlcov/index.html` +0. Make sure that coverage is at :100:% `./script/coverage` and open `htmlcov/index.html` * You can open PRs for :eyes: & discussion prior to this 0. Push to your fork and submit a pull request