diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 13:36:08 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 13:36:08 +0000 |
commit | b4b0cf43af51fe96f1a45bfede12e86d96f8b74d (patch) | |
tree | 2518497d75b7400758bc0abc5de2ca6f66f76a20 | |
parent | 351f57d62e19e9635cfe681530132a5e4e41af89 (diff) |
automatic import of python-business-pythonopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-business-python.spec | 591 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 593 insertions, 0 deletions
@@ -0,0 +1 @@ +/business-python-2.0.3.tar.gz diff --git a/python-business-python.spec b/python-business-python.spec new file mode 100644 index 0000000..a637554 --- /dev/null +++ b/python-business-python.spec @@ -0,0 +1,591 @@ +%global _empty_manifest_terminate_build 0 +Name: python-business-python +Version: 2.0.3 +Release: 1 +Summary: Date calculations based on business calendars. +License: MIT License +URL: https://github.com/gocardless/business-python +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/c1/69/d317fd75249e67a36bb6c96f4c7d90bb120bb7834e7378d12d76aac1ce9f/business-python-2.0.3.tar.gz +BuildArch: noarch + +Requires: python3-importlib_metadata +Requires: python3-dateutil +Requires: python3-pyyaml + +%description +# Business (Python) + +[](https://app.circleci.com/pipelines/github/gocardless/business-python) [](https://badge.fury.io/py/business-python) + +Date calculations based on business calendars. (Python 3.6+) + +Python implementation of https://github.com/gocardless/business + +## Documentation + +To get business, simply: + +```bash +$ pip install business-python +``` + +## Version 2.0.0 breaking changes + +In version 2.0.0 we have removed the bundled calendars. If you still need these they are available on [v1.0.1](https://github.com/gocardless/business-python/tree/74fe7e4068e0f16b68e7478f8b5ca1cc52f9a7d0/business/data). + +### Migration + +- Download/create calendars to a directory within your project eg: `lib/calendars` +- Change your code to include the `load_path` for your calendars +- Continue using `.load("my_calendar")` as usual + +```python +# lib/calendars contains yml files +Calendar.load_paths = ['lib/calendars'] +calendar = Calendar.load("my_calendar") +``` + +### Getting started + +Get started with business by creating an instance of the calendar class, passing in a hash that specifies which days of the week are considered working days, and which days are holidays. + +```python +from business.calendar import Calendar + +calendar = Calendar( + working_days=["monday", "tuesday", "wednesday", "thursday", "friday"], + # array items are either parseable date strings, or real datetime.date objects + holidays=["January 1st, 2020", "April 10th, 2020"], + extra_working_dates=[], +) +``` + +`extra_working_dates` key makes the calendar to consider a weekend day as a working day. + +If `working_days` is missing, then common default is used (mon-fri). +If `holidays` is missing, "no holidays" assumed. +If `extra_working_dates` is missing, then no changes in `working_days` will happen. + +Elements of `holidays` and `extra_working_dates` may be either strings that `Calendar.parse_date()` can understand, or YYYY-MM-DD (which is considered as a Date by Python YAML itself). + +#### Calendar YAML file example + +```yaml +# lib/calendars/my_calendar.yml +working_days: + - Monday + - Sunday +holidays: + - 2017-01-08 # Same as January 8th, 2017 +extra_working_dates: + - 2020-12-26 # Will consider 26 Dec 2020 (A Saturday), a working day +``` + +The `load_cache` method allows a thread safe way to avoid reloading the same calendar multiple times, and provides a performant way to dynamically load calendars for different requests. + +#### Using business-python + +Define your calendars in a folder eg: `lib/calendars` and set this directory on `Calendar.load_paths=` + +```python +Calendar.load_paths = ['lib/calendars'] +calendar = Calendar.load_cache("my_calendar") +``` + +### Input data types + +The `parse_date` method is used to process the input date(s) in each method and return a `datetime.date` object. + +```python +Calendar.parse_date("2019-01-01") +# => datetime.date(2019, 1, 1) +``` + +Supported data types are: + +- `datetime.date` +- `datetime.datetime` +- `pandas.Timestamp` (treated as `datetime.datetime`) +- date string parseable by [`dateutil.parser.parse`](https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse) + +`numpy.datetime64` is not supported, but can be converted to `datetime.date`: + +```python +numpy.datetime64('2014-06-01T23:00:05.453000000').astype('M8[D]').astype('O') +# => datetime.date(2014, 6, 1) +``` + +### Checking for business days + +To check whether a given date is a business day (falls on one of the specified working days or extra working dates, and is not a holiday), use the `is_business_day` method on `Calendar`. + +```python +calendar.is_business_day("Monday, 8 June 2020") +# => true +calendar.is_business_day("Sunday, 7 June 2020") +# => false +``` + +### Business day arithmetic + +> For our purposes, date-based calculations are sufficient. Supporting time-based calculations as well makes the code significantly more complex. We chose to avoid this extra complexity by sticking solely to date-based mathematics. + +The `add_business_days` method is used to perform business day arithmetic on dates. + +```python +input_date = Calendar.parse_date("Thursday, 12 June 2014") +calendar.add_business_days(input_date, 4).strftime("%A, %d %B %Y") +# => "Wednesday, 18 June 2014" +calendar.add_business_days(input_date, -4).strftime("%A, %d %B %Y") +# => "Friday, 06 June 2014" +``` + +The `roll_forward` and `roll_backward` methods snap a date to a nearby business day. If provided with a business day, they will return that date. Otherwise, they will advance (forward for `roll_forward` and backward for `roll_backward`) until a business day is found. + +```python +input_date = Calendar.parse_date("Saturday, 14 June 2014") +calendar.roll_forward(input_date).strftime("%A, %d %B %Y") +# => "Monday, 16 June 2014" +calendar.roll_backward(input_date).strftime("%A, %d %B %Y") +# => "Friday, 13 June 2014" +``` + +In contrast, the `next_business_day` and `previous_business_day` methods will always move to a next or previous date until a business day is found, regardless if the input provided is a business day. + +```python +input_date = Calendar.parse_date("Monday, 9 June 2014") +calendar.roll_forward(input_date).strftime("%A, %d %B %Y") +# => "Monday, 09 June 2014" +calendar.next_business_day(input_date).strftime("%A, %d %B %Y") +# => "Tuesday, 10 June 2014" +calendar.previous_business_day(input_date).strftime("%A, %d %B %Y") +# => "Friday, 06 June 2014" +``` + +To count the number of business days between two dates, pass the dates to `business_days_between`. This method counts from start of the first date to start of the second date. So, assuming no holidays, there would be two business days between a Monday and a Wednesday. + +```python +from datetime import timedelta + +input_date = Calendar.parse_date("Saturday, 14 June 2014") +calendar.business_days_between(input_date, input_date + timedelta(days=7)) +# => 5 +``` + +The `get_business_day_of_month` method return the running total of business days for a given date in that month. This method counts the number of business days from the start of the first day of the month to the given input date. + +```python +input_date = Calendar.parse_date("Thursday, 12 June 2014") +calendar.get_business_day_of_month(input_date) +# => 9 +``` +## License & Contributing + +- This is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). +- Bug reports and pull requests are welcome on GitHub at https://github.com/gocardless/business-python. + +GoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/about/jobs). + + +%package -n python3-business-python +Summary: Date calculations based on business calendars. +Provides: python-business-python +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-business-python +# Business (Python) + +[](https://app.circleci.com/pipelines/github/gocardless/business-python) [](https://badge.fury.io/py/business-python) + +Date calculations based on business calendars. (Python 3.6+) + +Python implementation of https://github.com/gocardless/business + +## Documentation + +To get business, simply: + +```bash +$ pip install business-python +``` + +## Version 2.0.0 breaking changes + +In version 2.0.0 we have removed the bundled calendars. If you still need these they are available on [v1.0.1](https://github.com/gocardless/business-python/tree/74fe7e4068e0f16b68e7478f8b5ca1cc52f9a7d0/business/data). + +### Migration + +- Download/create calendars to a directory within your project eg: `lib/calendars` +- Change your code to include the `load_path` for your calendars +- Continue using `.load("my_calendar")` as usual + +```python +# lib/calendars contains yml files +Calendar.load_paths = ['lib/calendars'] +calendar = Calendar.load("my_calendar") +``` + +### Getting started + +Get started with business by creating an instance of the calendar class, passing in a hash that specifies which days of the week are considered working days, and which days are holidays. + +```python +from business.calendar import Calendar + +calendar = Calendar( + working_days=["monday", "tuesday", "wednesday", "thursday", "friday"], + # array items are either parseable date strings, or real datetime.date objects + holidays=["January 1st, 2020", "April 10th, 2020"], + extra_working_dates=[], +) +``` + +`extra_working_dates` key makes the calendar to consider a weekend day as a working day. + +If `working_days` is missing, then common default is used (mon-fri). +If `holidays` is missing, "no holidays" assumed. +If `extra_working_dates` is missing, then no changes in `working_days` will happen. + +Elements of `holidays` and `extra_working_dates` may be either strings that `Calendar.parse_date()` can understand, or YYYY-MM-DD (which is considered as a Date by Python YAML itself). + +#### Calendar YAML file example + +```yaml +# lib/calendars/my_calendar.yml +working_days: + - Monday + - Sunday +holidays: + - 2017-01-08 # Same as January 8th, 2017 +extra_working_dates: + - 2020-12-26 # Will consider 26 Dec 2020 (A Saturday), a working day +``` + +The `load_cache` method allows a thread safe way to avoid reloading the same calendar multiple times, and provides a performant way to dynamically load calendars for different requests. + +#### Using business-python + +Define your calendars in a folder eg: `lib/calendars` and set this directory on `Calendar.load_paths=` + +```python +Calendar.load_paths = ['lib/calendars'] +calendar = Calendar.load_cache("my_calendar") +``` + +### Input data types + +The `parse_date` method is used to process the input date(s) in each method and return a `datetime.date` object. + +```python +Calendar.parse_date("2019-01-01") +# => datetime.date(2019, 1, 1) +``` + +Supported data types are: + +- `datetime.date` +- `datetime.datetime` +- `pandas.Timestamp` (treated as `datetime.datetime`) +- date string parseable by [`dateutil.parser.parse`](https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse) + +`numpy.datetime64` is not supported, but can be converted to `datetime.date`: + +```python +numpy.datetime64('2014-06-01T23:00:05.453000000').astype('M8[D]').astype('O') +# => datetime.date(2014, 6, 1) +``` + +### Checking for business days + +To check whether a given date is a business day (falls on one of the specified working days or extra working dates, and is not a holiday), use the `is_business_day` method on `Calendar`. + +```python +calendar.is_business_day("Monday, 8 June 2020") +# => true +calendar.is_business_day("Sunday, 7 June 2020") +# => false +``` + +### Business day arithmetic + +> For our purposes, date-based calculations are sufficient. Supporting time-based calculations as well makes the code significantly more complex. We chose to avoid this extra complexity by sticking solely to date-based mathematics. + +The `add_business_days` method is used to perform business day arithmetic on dates. + +```python +input_date = Calendar.parse_date("Thursday, 12 June 2014") +calendar.add_business_days(input_date, 4).strftime("%A, %d %B %Y") +# => "Wednesday, 18 June 2014" +calendar.add_business_days(input_date, -4).strftime("%A, %d %B %Y") +# => "Friday, 06 June 2014" +``` + +The `roll_forward` and `roll_backward` methods snap a date to a nearby business day. If provided with a business day, they will return that date. Otherwise, they will advance (forward for `roll_forward` and backward for `roll_backward`) until a business day is found. + +```python +input_date = Calendar.parse_date("Saturday, 14 June 2014") +calendar.roll_forward(input_date).strftime("%A, %d %B %Y") +# => "Monday, 16 June 2014" +calendar.roll_backward(input_date).strftime("%A, %d %B %Y") +# => "Friday, 13 June 2014" +``` + +In contrast, the `next_business_day` and `previous_business_day` methods will always move to a next or previous date until a business day is found, regardless if the input provided is a business day. + +```python +input_date = Calendar.parse_date("Monday, 9 June 2014") +calendar.roll_forward(input_date).strftime("%A, %d %B %Y") +# => "Monday, 09 June 2014" +calendar.next_business_day(input_date).strftime("%A, %d %B %Y") +# => "Tuesday, 10 June 2014" +calendar.previous_business_day(input_date).strftime("%A, %d %B %Y") +# => "Friday, 06 June 2014" +``` + +To count the number of business days between two dates, pass the dates to `business_days_between`. This method counts from start of the first date to start of the second date. So, assuming no holidays, there would be two business days between a Monday and a Wednesday. + +```python +from datetime import timedelta + +input_date = Calendar.parse_date("Saturday, 14 June 2014") +calendar.business_days_between(input_date, input_date + timedelta(days=7)) +# => 5 +``` + +The `get_business_day_of_month` method return the running total of business days for a given date in that month. This method counts the number of business days from the start of the first day of the month to the given input date. + +```python +input_date = Calendar.parse_date("Thursday, 12 June 2014") +calendar.get_business_day_of_month(input_date) +# => 9 +``` +## License & Contributing + +- This is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). +- Bug reports and pull requests are welcome on GitHub at https://github.com/gocardless/business-python. + +GoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/about/jobs). + + +%package help +Summary: Development documents and examples for business-python +Provides: python3-business-python-doc +%description help +# Business (Python) + +[](https://app.circleci.com/pipelines/github/gocardless/business-python) [](https://badge.fury.io/py/business-python) + +Date calculations based on business calendars. (Python 3.6+) + +Python implementation of https://github.com/gocardless/business + +## Documentation + +To get business, simply: + +```bash +$ pip install business-python +``` + +## Version 2.0.0 breaking changes + +In version 2.0.0 we have removed the bundled calendars. If you still need these they are available on [v1.0.1](https://github.com/gocardless/business-python/tree/74fe7e4068e0f16b68e7478f8b5ca1cc52f9a7d0/business/data). + +### Migration + +- Download/create calendars to a directory within your project eg: `lib/calendars` +- Change your code to include the `load_path` for your calendars +- Continue using `.load("my_calendar")` as usual + +```python +# lib/calendars contains yml files +Calendar.load_paths = ['lib/calendars'] +calendar = Calendar.load("my_calendar") +``` + +### Getting started + +Get started with business by creating an instance of the calendar class, passing in a hash that specifies which days of the week are considered working days, and which days are holidays. + +```python +from business.calendar import Calendar + +calendar = Calendar( + working_days=["monday", "tuesday", "wednesday", "thursday", "friday"], + # array items are either parseable date strings, or real datetime.date objects + holidays=["January 1st, 2020", "April 10th, 2020"], + extra_working_dates=[], +) +``` + +`extra_working_dates` key makes the calendar to consider a weekend day as a working day. + +If `working_days` is missing, then common default is used (mon-fri). +If `holidays` is missing, "no holidays" assumed. +If `extra_working_dates` is missing, then no changes in `working_days` will happen. + +Elements of `holidays` and `extra_working_dates` may be either strings that `Calendar.parse_date()` can understand, or YYYY-MM-DD (which is considered as a Date by Python YAML itself). + +#### Calendar YAML file example + +```yaml +# lib/calendars/my_calendar.yml +working_days: + - Monday + - Sunday +holidays: + - 2017-01-08 # Same as January 8th, 2017 +extra_working_dates: + - 2020-12-26 # Will consider 26 Dec 2020 (A Saturday), a working day +``` + +The `load_cache` method allows a thread safe way to avoid reloading the same calendar multiple times, and provides a performant way to dynamically load calendars for different requests. + +#### Using business-python + +Define your calendars in a folder eg: `lib/calendars` and set this directory on `Calendar.load_paths=` + +```python +Calendar.load_paths = ['lib/calendars'] +calendar = Calendar.load_cache("my_calendar") +``` + +### Input data types + +The `parse_date` method is used to process the input date(s) in each method and return a `datetime.date` object. + +```python +Calendar.parse_date("2019-01-01") +# => datetime.date(2019, 1, 1) +``` + +Supported data types are: + +- `datetime.date` +- `datetime.datetime` +- `pandas.Timestamp` (treated as `datetime.datetime`) +- date string parseable by [`dateutil.parser.parse`](https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse) + +`numpy.datetime64` is not supported, but can be converted to `datetime.date`: + +```python +numpy.datetime64('2014-06-01T23:00:05.453000000').astype('M8[D]').astype('O') +# => datetime.date(2014, 6, 1) +``` + +### Checking for business days + +To check whether a given date is a business day (falls on one of the specified working days or extra working dates, and is not a holiday), use the `is_business_day` method on `Calendar`. + +```python +calendar.is_business_day("Monday, 8 June 2020") +# => true +calendar.is_business_day("Sunday, 7 June 2020") +# => false +``` + +### Business day arithmetic + +> For our purposes, date-based calculations are sufficient. Supporting time-based calculations as well makes the code significantly more complex. We chose to avoid this extra complexity by sticking solely to date-based mathematics. + +The `add_business_days` method is used to perform business day arithmetic on dates. + +```python +input_date = Calendar.parse_date("Thursday, 12 June 2014") +calendar.add_business_days(input_date, 4).strftime("%A, %d %B %Y") +# => "Wednesday, 18 June 2014" +calendar.add_business_days(input_date, -4).strftime("%A, %d %B %Y") +# => "Friday, 06 June 2014" +``` + +The `roll_forward` and `roll_backward` methods snap a date to a nearby business day. If provided with a business day, they will return that date. Otherwise, they will advance (forward for `roll_forward` and backward for `roll_backward`) until a business day is found. + +```python +input_date = Calendar.parse_date("Saturday, 14 June 2014") +calendar.roll_forward(input_date).strftime("%A, %d %B %Y") +# => "Monday, 16 June 2014" +calendar.roll_backward(input_date).strftime("%A, %d %B %Y") +# => "Friday, 13 June 2014" +``` + +In contrast, the `next_business_day` and `previous_business_day` methods will always move to a next or previous date until a business day is found, regardless if the input provided is a business day. + +```python +input_date = Calendar.parse_date("Monday, 9 June 2014") +calendar.roll_forward(input_date).strftime("%A, %d %B %Y") +# => "Monday, 09 June 2014" +calendar.next_business_day(input_date).strftime("%A, %d %B %Y") +# => "Tuesday, 10 June 2014" +calendar.previous_business_day(input_date).strftime("%A, %d %B %Y") +# => "Friday, 06 June 2014" +``` + +To count the number of business days between two dates, pass the dates to `business_days_between`. This method counts from start of the first date to start of the second date. So, assuming no holidays, there would be two business days between a Monday and a Wednesday. + +```python +from datetime import timedelta + +input_date = Calendar.parse_date("Saturday, 14 June 2014") +calendar.business_days_between(input_date, input_date + timedelta(days=7)) +# => 5 +``` + +The `get_business_day_of_month` method return the running total of business days for a given date in that month. This method counts the number of business days from the start of the first day of the month to the given input date. + +```python +input_date = Calendar.parse_date("Thursday, 12 June 2014") +calendar.get_business_day_of_month(input_date) +# => 9 +``` +## License & Contributing + +- This is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). +- Bug reports and pull requests are welcome on GitHub at https://github.com/gocardless/business-python. + +GoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/about/jobs). + + +%prep +%autosetup -n business-python-2.0.3 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-business-python -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 2.0.3-1 +- Package Spec generated @@ -0,0 +1 @@ +b354d51d6fe45f235a6ec8ac5907a843 business-python-2.0.3.tar.gz |