Skip to main content

Is a package that simplifies accessing and managing Brazilian national holidays. It fetches holiday data directly from ANBIMA, allowing you to easily retrieve holiday dates, names, and weekdays, as well as check if a specific date is a holiday. The package offers a straightforward interface for querying and interacting with holiday information.

Project description

Brazil National Days

brazil_national_days is a package designed to simplify the retrieval and management of Brazilian national holidays. The package provides an easy-to-use interface for downloading, parsing, and querying holiday data directly from the ANBIMA website. This package can be used to check for national holidays, obtain the dates and names of holidays, and determine whether a specific date is a holiday.

Installation

To install the package, you can use pip:

    pip install brazil_national_days

Use

Here is a basic example of how to use the brazil_national_days package:

1. Import the Package

from brazil_national_days import Controller

2. Instantiate the Controller

controller = Controller()

3. Use the Controller

# Get all weekdays corresponding to national holidays
national_days = controller.get_national_days()

# Get all national holiday dates
national_dates = controller.get_national_dates()

# Get all national holiday names
national_holidays = controller.get_national_holidays()

# Get weekdays by a specific holiday name
holiday_name = "Carnaval"
holiday_days = controller.get_national_days_by_holiday(holiday_name)

# Get dates by a specific holiday name
holiday_dates = controller.get_national_dates_by_holiday(holiday_name)

# Check if a specific date is a holiday
date_to_check = "2024-02-12"
is_holiday = controller.is_holiday(date_to_check)

Class and Method Details

Clients

This class is used to fetch and prepare the holiday data.

Attributes:

  • URL (str): The URL to the ANBIMA Excel file containing the national holidays.
  • data (pd.DataFrame): A DataFrame that holds the processed holiday data.

Methods:

  • get_national_holidays() -> pd.DataFrame: Downloads the Excel file from the provided URL, processes the data, and returns it as a pandas DataFrame. The dates are converted to datetime.date objects. If an error occurs during the request or parsing, the method handles the exceptions and returns None.

Controller

This class provides methods to interact with the holiday data fetched by the Client.

Attributes:

  • __data (pd.DataFrame): A private attribute that stores the national holiday data fetched by the Client.

Methods:

  • get_national_days() -> list: Returns a list of weekdays corresponding to all national holidays.
  • get_national_dates() -> list: Returns a list of dates for all national holidays.
  • get_national_holidays() -> list: Returns a list of names of all national holidays.
  • get_national_days_by_holiday(holiday: str) -> pd.Series: Returns a Series of weekdays for a specific holiday.
  • get_national_dates_by_holiday(holiday: str) -> pd.Series: Returns a Series of dates for a specific holiday.
  • is_holiday(date: Union[str, datetime.date]) -> bool: Checks if a given date is a national holiday. Accepts both string ("YYYY-MM-DD") and datetime.date objects.

Error Handling

The package is designed to handle various errors, such as:

  • Network issues when fetching the data.
  • Parsing errors with the Excel file.
  • Incorrect date formats when checking holidays.

Contributing

If you'd like to contribute to this project, feel free to fork the repository, make changes, and submit a pull request. All contributions are welcome!

Licença

MIT License

Copyright (c) [2024] [Leonardo Alves Francisco]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brazil_national_days-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file brazil_national_days-0.0.1.tar.gz.

File metadata

  • Download URL: brazil_national_days-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for brazil_national_days-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b23bd752ff22ed484f90a3b86715563876234fcb57bb510129c62c58414f87a5
MD5 f785a54b2d1569eb32d3db07e286c290
BLAKE2b-256 94f71d34360644baac5c3a805eafa628a1a5b8e0bb4f35d2a535455260adfc8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page