Skip to content

Commit

Permalink
v1: update entities location
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Jun 6, 2024
1 parent 6c80453 commit a3fba08
Show file tree
Hide file tree
Showing 323 changed files with 264 additions and 213 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- rst

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
rev: v0.4.8
hooks:
- id: ruff
- id: ruff-format
Expand Down
33 changes: 16 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ timestamps:
'1/1/2014' in us_holidays # True
1388597445 in us_holidays # True
Some holidays may be only present in parts of a country:
Some holidays may be only present in parts of an entity:

.. code-block:: python
Expand All @@ -138,35 +138,35 @@ Please see the `python-holidays documentation`_ for additional examples and
detailed information.


Available Countries
-------------------
Available ISO 3166 Entities
---------------------------

.. _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
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

We currently support 148 country codes. The standard way to refer to a country
We currently support 148 ISO 3166 entity codes. The standard way to refer to an entity
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`_. Some countries have common or foreign
for a subdivision its `ISO 3166-2 code`_. Some entities have common or foreign
names or abbreviations as aliases for their subdivisions. These are defined in
the (optional) ``subdivisions_aliases`` attribute.
Some of the countries support more than one language for holiday names output.
Some of the entities support more than one language for holiday names output.
A default language is defined by ``default_language`` (optional) attribute
for each entity and is used as a fallback when neither user specified
language nor user locale language available. The default language code is
a `ISO 639-1 code`_. A list of all languages supported by country is defined by
a `ISO 639-1 code`_. A list of all languages supported by entity is defined by
``supported_languages`` (optional) attribute. If there is no designated
`ISO 639-1 code`_ then `ISO 639-2 code`_ can be used.

Many countries have other categories of holidays in addition to common (national-wide) holidays:
Many entities have other categories of holidays in addition to common (national-wide) holidays:
bank holidays, school holidays, additional (paid or non-paid) holidays, holidays of state or
public employees, religious holidays (valid only for these religions followers). A list of all
categories supported by country is defined by ``supported_categories`` (optional) attribute.
categories supported by entity is defined by ``supported_categories`` (optional) attribute.

The following is a list of supported countries, their subdivisions followed by their
The following is a list of supported entities, their subdivisions followed by their
aliases (if any) in brackets, available languages and additional holiday categories.
All countries support **PUBLIC** holidays category by default.
All entities support **PUBLIC** holidays category by default.
All other default values are highlighted with bold:


Expand All @@ -175,7 +175,7 @@ All other default values are highlighted with bold:
:header-rows: 1
:class: tight-table

* - Country
* - Entity
- Code
- Subdivisions
- Supported Languages
Expand Down Expand Up @@ -927,14 +927,13 @@ All other default values are highlighted with bold:
-


Available Financial Markets
===========================
Available ISO 10383 Entities
============================

.. _ISO 10383 MIC: https://www.iso20022.org/market-identifier-codes

The standard way to refer to a financial market is to use its `ISO 10383 MIC`_
(Market Identifier Code) as a "country" code when available. The
following financial markets are available:
The standard way to refer to an ISO 10383 entity is to use its `ISO 10383 MIC`_
(Market Identifier Code). The following ISO 10383 entities are available:

.. list-table::
:widths: 23 4 83
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ functions to create the object using a string with the country code:
.. code-block:: python
>>> us_holidays = holidays.country_holidays('US')
>>> nyse_holidays = holidays.financial_holidays('NYSE')
>>> nyse_holidays = holidays.entities.iso10383_holidays('NYSE')
Let's print out the holidays in 2014 specific to California, USA:

Expand Down Expand Up @@ -238,7 +238,7 @@ to override is :py:meth:`_populate`:

.. code-block:: python
>>> from holidays.countries import US
>>> from holidays.entities.iso3166 import US
>>> class CorporateHolidays(US):
>>> def _populate(self, year):
>>> # Populate the holiday list with the default US holidays.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Supported Entities
:toctree: _autosummary
:recursive:

holidays.countries
holidays.financial
holidays.entities.iso3166
holidays.entities.iso10383
4 changes: 2 additions & 2 deletions holidays/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
__version__ = "0.51"


EntityLoader.load("countries", globals())
EntityLoader.load("financial", globals())
EntityLoader.load("iso3166", globals())
EntityLoader.load("iso10383", globals())

warnings.warn(
FUTURE_INCOMPATIBILITY_WARNING_TEMPLATE.format(version=__version__),
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions holidays/entities/iso10383/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# [ISO-10383 entities](https://en.wikipedia.org/wiki/Market_Identifier_Code)

ISO 10383 is the ISO standard that specifies a universal method of identifying exchanges, trading platforms and regulated or non-regulated markets as sources of prices and related information in order to facilitate automated processing.

Additional information:

- <https://www.iso20022.org/market-identifier-codes>
- <https://www.iso.org/standard/61067.html>
- <https://www.tradinghours.com/mic>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions holidays/entities/iso3166/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [ISO-3166 entities](https://en.wikipedia.org/wiki/ISO_3166)

ISO 3166-1 alpha-2 codes are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard[1] published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest. They are the most widely used of the country codes published by ISO (the others being alpha-3 and numeric), and are used most prominently for the Internet's country code top-level domains (with a few exceptions).

ISO 3166-1 alpha-3 codes are three-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest. They allow a better visual association between the codes and the country names than the two-letter alpha-2 codes (the third set of codes is numeric and hence offers no visual association).

ISO 3166-2 is part of the ISO 3166 standard published by the International Organization for Standardization (ISO), and defines codes for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1.

Additional information:

- <https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes>
- <https://www.iso.org/obp/ui/#search>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from holidays.constants import PUBLIC, UNOFFICIAL
from holidays.countries.united_states import US
from holidays.entities.iso3166.united_states import US


class HolidaysAS(US):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from holidays.constants import PUBLIC, UNOFFICIAL
from holidays.countries.united_states import US
from holidays.entities.iso3166.united_states import US


class HolidaysGU(US):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.united_kingdom import UnitedKingdom, UnitedKingdomStaticHolidays
from holidays.entities.iso3166.united_kingdom import UnitedKingdom, UnitedKingdomStaticHolidays
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_SUN_TO_NEXT_MON

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from holidays.constants import PUBLIC, UNOFFICIAL
from holidays.countries.united_states import US
from holidays.entities.iso3166.united_states import US


class HolidaysMP(US):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from holidays.constants import PUBLIC, UNOFFICIAL
from holidays.countries.united_states import US
from holidays.entities.iso3166.united_states import US


class HolidaysPR(US):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from holidays.constants import PUBLIC, UNOFFICIAL
from holidays.countries.united_states import US
from holidays.entities.iso3166.united_states import US


class HolidaysUM(US):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from holidays.constants import PUBLIC, UNOFFICIAL
from holidays.countries.united_states import US
from holidays.entities.iso3166.united_states import US


class HolidaysVI(US):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion holidays/holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def __repr__(self) -> str:

parts = []
if hasattr(self, "market"):
parts.append(f"holidays.financial_holidays({self.market!r}")
parts.append(f"holidays.entities.iso10383_holidays({self.market!r}")
parts.append(")")
elif hasattr(self, "country"):
parts.append(f"holidays.country_holidays({self.country!r}")
Expand Down
8 changes: 4 additions & 4 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def __init__(self, path: str, *args, **kwargs) -> None:
"This is a python-holidays entity loader class. "
"For entity inheritance purposes please import a class you "
"want to derive from directly: e.g., "
"`from holidays.countries import Entity` or "
"`from holidays.financial import Entity`."
"`from holidays.entities.iso3166 import Entity` or "
"`from holidays.entities.financial import Entity`."
)

entity_path = path.split(".")
Expand Down Expand Up @@ -273,11 +273,11 @@ def get_financial_codes(include_aliases: bool = True) -> Iterable[str]:
@staticmethod
def load(prefix: str, scope: Dict) -> None:
"""Load country or financial entities."""
entity_mapping = COUNTRIES if prefix == "countries" else FINANCIAL
entity_mapping = COUNTRIES if prefix == "iso3166" else FINANCIAL
for module, entities in entity_mapping.items():
scope.update(
{
entity: EntityLoader(f"holidays.{prefix}.{module}.{entity}")
entity: EntityLoader(f"holidays.entities.{prefix}.{module}.{entity}")
for entity in entities
}
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ select = ["E4", "E7", "E9", "F", "T"]
max-string-length = 99

[[tool.mypy.overrides]]
module = "holidays.countries.*"
module = "holidays.entities.*"
disable_error_code = ["override"]

[[tool.mypy.overrides]]
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions tests/entities/iso10383/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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: Vacanza Team and individual contributors (see AUTHORS file)
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.financial.european_central_bank import EuropeanCentralBank, ECB, TAR
from holidays.entities.iso10383.european_central_bank import EuropeanCentralBank, ECB, TAR
from tests.common import CommonFinancialTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.financial.ice_futures_europe import ICEFuturesEurope, IFEU
from holidays.entities.iso10383.ice_futures_europe import ICEFuturesEurope, IFEU
from tests.common import CommonFinancialTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
SAT,
SUN,
)
from holidays.financial.ny_stock_exchange import NewYorkStockExchange, NYSE, XNYS
from holidays.entities.iso10383.ny_stock_exchange import NewYorkStockExchange, NYSE, XNYS
from tests.common import CommonFinancialTests


Expand Down
11 changes: 11 additions & 0 deletions tests/entities/iso3166/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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: Vacanza Team and individual contributors (see AUTHORS file)
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.albania import Albania, AL, ALB
from holidays.entities.iso3166.albania import Albania, AL, ALB
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.algeria import Algeria, DZ, DZA
from holidays.entities.iso3166.algeria import Algeria, DZ, DZA
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from holidays.calendars.gregorian import DEC
from holidays.constants import UNOFFICIAL
from holidays.countries.american_samoa import HolidaysAS, AS, ASM
from holidays.entities.iso3166.american_samoa import HolidaysAS, AS, ASM
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.andorra import Andorra, AD, AND
from holidays.entities.iso3166.andorra import Andorra, AD, AND
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.angola import Angola, AO, AGO
from holidays.entities.iso3166.angola import Angola, AO, AGO
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.argentina import Argentina, AR, ARG
from holidays.entities.iso3166.argentina import Argentina, AR, ARG
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.armenia import Armenia, AM, ARM
from holidays.entities.iso3166.armenia import Armenia, AM, ARM
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from unittest import TestCase

from holidays.countries.aruba import Aruba, AW, ABW
from holidays.entities.iso3166.aruba import Aruba, AW, ABW
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from holidays.calendars.gregorian import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, NOV, DEC
from holidays.constants import BANK, HALF_DAY, PUBLIC
from holidays.countries.australia import Australia, AU, AUS
from holidays.entities.iso3166.australia import Australia, AU, AUS
from tests.common import CommonCountryTests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from unittest import TestCase

from holidays.constants import BANK
from holidays.countries.austria import Austria, AT, AUT
from holidays.entities.iso3166.austria import Austria, AT, AUT
from tests.common import CommonCountryTests


Expand Down
Loading

0 comments on commit a3fba08

Please sign in to comment.