Skip to content

Commit

Permalink
Add ISO 3166-1 for overseas departments and regions of France
Browse files Browse the repository at this point in the history
  • Loading branch information
KJhellico committed Mar 31, 2023
1 parent 635a97f commit bb780d5
Show file tree
Hide file tree
Showing 28 changed files with 920 additions and 10 deletions.
14 changes: 8 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
rev: 23.1.0
hooks:
- id: black
exclude: ^(docs|scripts/l10n/msgfmt.py)
exclude: ^docs
language_version: python3

- repo: https://github.com/pycqa/flake8
Expand All @@ -26,16 +26,18 @@ repos:
additional_dependencies:
- flake8-print
args: [--max-line-length=79]
exclude: ^(docs|scripts/l10n/msgfmt.py)
exclude: ^docs

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
# holidays/countries/__init__.py is excluded due to a bug whereby
# black and isort don't agree and enter into an infinite fix loop.
# TODO remove this exclusion when isort and black play nice again.
exclude: ^(docs|holidays/countries/__init__.py|scripts/l10n/msgfmt.py)
# holidays/countries/__init__.py and
# tests/countries/test_french_southern_territories.py
# is excluded due to a bug whereby black and isort don't agree
# and enter into an infinite fix loop.
# TODO remove this exclusions when isort and black play nice again.
exclude: ^(docs|holidays/countries/__init__.py|tests/countries/test_french_southern_territories.py)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
Expand Down
40 changes: 38 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Available Countries
.. _ISO 3166-1 alpha-2 code: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
.. _ISO 3166-2 code: https://en.wikipedia.org/wiki/ISO_3166-2

We currently support 120 country codes. The standard way to refer to a country
We currently support 132 country codes. The standard way to refer to a country
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
for a subdivision its `ISO 3166-2 code`_. The following countries and
subdivisions are available:
Expand Down Expand Up @@ -236,7 +236,13 @@ subdivisions are available:
- None
* - France
- FR
- Départements: Alsace-Moselle, Guadeloupe, Guyane, La Réunion, Martinique, Mayotte, Métropole, Nouvelle-Calédonie, Polynésie Française, Saint-Barthélémy, Saint-Martin, Wallis-et-Futuna
- Departments: Alsace-Moselle, Guadeloupe, Guyane, La Réunion, Martinique, Mayotte, Métropole, Nouvelle-Calédonie, Polynésie Française, Saint-Barthélémy, Saint-Martin, Wallis-et-Futuna
* - French Polynesia
- PF
- None; Can also be loaded as country FR, subdivision Polynésie Française
* - French Southern Territories
- TF
- None
* - Georgia
- GE
- None
Expand All @@ -246,9 +252,15 @@ subdivisions are available:
* - Greece
- GR
- None
* - Guadeloupe
- GP
- None; Can also be loaded as country FR, subdivision Guadeloupe
* - Guam
- GU
- None; Can also be loaded as country US, subdivision GU
* - Guyana
- GY
- None; Can also be loaded as country FR, subdivision Guyane
* - Honduras
- HN
- None
Expand Down Expand Up @@ -324,6 +336,12 @@ subdivisions are available:
* - Marshall Islands (the)
- MH
- None
* - Martinique
- MQ
- None; Can also be loaded as country FR, subdivision Martinique
* - Mayotte
- YT
- None; Can also be loaded as country FR, subdivision Mayotte
* - Mexico
- MX
- None
Expand All @@ -348,6 +366,9 @@ subdivisions are available:
* - Netherlands
- NL
- None
* - New Caledonia
- NC
- None; Can also be loaded as country FR, subdivision Nouvelle-Calédonie
* - New Zealand
- NZ
- Regions: AUK, CAN, HKB, MBH, NSN, NTL, OTA, STL, TKI, WGN, WTC, CIT. Sub-regions: South Canterbury
Expand Down Expand Up @@ -390,12 +411,24 @@ subdivisions are available:
* - Puerto Rico
- PR
- None; Can also be loaded as country US, subdivision PR
* - Reunion
- RE
- None; Can also be loaded as country FR, subdivision La Réunion
* - Romania
- RO
- None
* - Russia
- RU
- None
* - Saint Barthelemy
- BL
- None; Can also be loaded as country FR, subdivision Saint-Barthélémy
* - Saint Martin
- MF
- None; Can also be loaded as country FR, subdivision Saint-Martin
* - Saint Pierre and Miquelon
- PM
- None
* - San Marino
- SM
- None
Expand Down Expand Up @@ -477,6 +510,9 @@ subdivisions are available:
* - Virgin Islands (U.S.)
- VI
- None; Can also be loaded as country US, subdivision VI
* - Wallis and Futuna
- WF
- None; Can also be loaded as country FR, subdivision Wallis-et-Futuna
* - Zambia
- ZM
- None
Expand Down
12 changes: 12 additions & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@
from .ethiopia import Ethiopia, ET, ETH
from .finland import Finland, FI, FIN
from .france import France, FR, FRA
from .french_polynesia import FrenchPolynesia, PF, PYF
from .french_southern_territories import FrenchSouthernTerritories, TF, ATF
from .georgia import Georgia, GE, GEO
from .germany import Germany, DE, DEU
from .greece import Greece, GR, GRC
from .guadeloupe import Guadeloupe, GP, GLP
from .guam import Guam, GU, GUM, HolidaysGU
from .guyana import Guyana, GY, GUY
from .honduras import Honduras, HN, HND
from .hongkong import HongKong, HK, HKG
from .hungary import Hungary, HU, HUN
Expand All @@ -77,6 +81,8 @@
from .malaysia import Malaysia, MY, MYS
from .malta import Malta, MT, MLT
from .marshall_islands import MarshallIslands, MH, MHL, HolidaysMH
from .martinique import Martinique, MQ, MTQ
from .mayotte import Mayotte, YT, MYT
from .mexico import Mexico, MX, MEX
from .moldova import Moldova, MD, MDA
from .monaco import Monaco, MC, MCO
Expand All @@ -85,6 +91,7 @@
from .mozambique import Mozambique, MZ, MOZ
from .namibia import Namibia, NA, NAM
from .netherlands import Netherlands, NL, NLD
from .new_caledonia import NewCaledonia, NC, NCL
from .new_zealand import NewZealand, NZ, NZL
from .nicaragua import Nicaragua, NI, NIC
from .nigeria import Nigeria, NG, NGA
Expand All @@ -104,8 +111,12 @@
from .poland import Poland, PL, POL
from .portugal import Portugal, PT, PRT
from .puerto_rico import PuertoRico, PR, PRI, HolidaysPR
from .reunion import Reunion, RE, REU
from .romania import Romania, RO, ROU
from .russia import Russia, RU, RUS
from .saint_barthelemy import SaintBarthelemy, BL, BLM
from .saint_martin import SaintMartin, MF, MAF
from .saint_pierre_and_miquelon import SaintPierreAndMiquelon, PM, SPM
from .san_marino import SanMarino, SM, SMR
from .saudi_arabia import SaudiArabia, SA, SAU
from .serbia import Serbia, RS, SRB
Expand Down Expand Up @@ -142,5 +153,6 @@
from .vatican_city import VaticanCity, VA, VAT
from .venezuela import Venezuela, VE, VEN
from .vietnam import Vietnam, VN, VNM
from .wallis_and_futuna import WallisAndFutuna, WF, WLF
from .zambia import Zambia, ZM, ZMB
from .zimbabwe import Zimbabwe, ZW, ZWE
33 changes: 33 additions & 0 deletions holidays/countries/french_polynesia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.france import FR


class FrenchPolynesia(FR):
# Alias of a FR subdivision that is also officially assigned its own
# country code in ISO 3166-1. See
# https://en.wikipedia.org/wiki/ISO_3166-2:FR#Subdivisions_included_in_ISO_3166-1

country = "PF"
subdivisions = []

def _populate(self, year: int) -> None:
self.subdiv = "Polynésie Française"
super()._populate(year)


class PF(FrenchPolynesia):
pass


class PYF(FrenchPolynesia):
pass
32 changes: 32 additions & 0 deletions holidays/countries/french_southern_territories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.france import FR


class FrenchSouthernTerritories(FR):
# Alias of a FR subdivision that is also officially assigned its own
# country code in ISO 3166-1. See
# https://en.wikipedia.org/wiki/ISO_3166-2:FR#Subdivisions_included_in_ISO_3166-1

country = "TF"
subdivisions = []

def _populate(self, year: int) -> None:
super()._populate(year)


class TF(FrenchSouthernTerritories):
pass


class ATF(FrenchSouthernTerritories):
pass
33 changes: 33 additions & 0 deletions holidays/countries/guadeloupe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.france import FR


class Guadeloupe(FR):
# Alias of a FR subdivision that is also officially assigned its own
# country code in ISO 3166-1. See
# https://en.wikipedia.org/wiki/ISO_3166-2:FR#Subdivisions_included_in_ISO_3166-1

country = "GP"
subdivisions = []

def _populate(self, year: int) -> None:
self.subdiv = "Guadeloupe"
super()._populate(year)


class GP(Guadeloupe):
pass


class GLP(Guadeloupe):
pass
33 changes: 33 additions & 0 deletions holidays/countries/guyana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.france import FR


class Guyana(FR):
# Alias of a FR subdivision that is also officially assigned its own
# country code in ISO 3166-1. See
# https://en.wikipedia.org/wiki/ISO_3166-2:FR#Subdivisions_included_in_ISO_3166-1

country = "GY"
subdivisions = []

def _populate(self, year: int) -> None:
self.subdiv = "Guyane"
super()._populate(year)


class GY(Guyana):
pass


class GUY(Guyana):
pass
33 changes: 33 additions & 0 deletions holidays/countries/martinique.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.france import FR


class Martinique(FR):
# Alias of a FR subdivision that is also officially assigned its own
# country code in ISO 3166-1. See
# https://en.wikipedia.org/wiki/ISO_3166-2:FR#Subdivisions_included_in_ISO_3166-1

country = "MQ"
subdivisions = []

def _populate(self, year: int) -> None:
self.subdiv = "Martinique"
super()._populate(year)


class MQ(Martinique):
pass


class MTQ(Martinique):
pass
33 changes: 33 additions & 0 deletions holidays/countries/mayotte.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.france import FR


class Mayotte(FR):
# Alias of a FR subdivision that is also officially assigned its own
# country code in ISO 3166-1. See
# https://en.wikipedia.org/wiki/ISO_3166-2:FR#Subdivisions_included_in_ISO_3166-1

country = "YT"
subdivisions = []

def _populate(self, year: int) -> None:
self.subdiv = "Mayotte"
super()._populate(year)


class YT(Mayotte):
pass


class MYT(Mayotte):
pass
Loading

0 comments on commit bb780d5

Please sign in to comment.