Name | pcontract JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | A data structure to track data over time. |
upload_time | 2024-01-19 20:30:21 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | Copyright (c) 2022, Şuayip Üzülmez All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
keywords |
contract
contract-management
data-tracking
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pcontract
A data structure to track data over time. It works by tracking time/schedule
information **rather than tracking data changes** over time.
## Reasoning
Let's assume you make a contract with a person (in this example,
assume it's a lease agreement). In the first draft, the parties agree on
some conditions, and if they are happy, they close the deal.
Now, assume after some time, one of the parties need to amend some
changes, (after the fact that the contract was in place), in which case the
original contract would be nulled and a new contract would be drafted.
This new contract now spans a different time period and the conditions are
changed.
In this case the tenant would have held of the leased place for some time
(say a month) until the amended contract was in place.
To account for this interval, amended contract could be drafted so that it would
encompass the past month.
However, the world of leasing is not perfect and sometimes one of the parties
will need to pursue this one-month interval according to the original contract
(e.g., the landlord increased the rent, but it will become effective in the
coming month). In such a case, there needs to be a contract for the one-month
interval since the original contract spans more than that.
As such, we need a way to create contracts and amend them without having to
think about these intervals; things get more complex if the amending is not
permanent but transitory (e.g., effective only for some limited time during
the original contract).
## How it works
In order to create a contract, you need to use a `Contract` type, which is a
container for `Branch` i.e, contracts. You may initialize a basic contract by:
```python
contract = Contract.init(
start_at=datetime(2022, 12, 1),
end_at=datetime(2023, 12, 1),
data={"hello": "world"},
)
```
The example above creates a contract that spans one year, with given data. In
order to amend a contract, you may use `Contract.branch`:
```
contract.branch(
start_at=datetime(2023, 6, 1),
data={"hello": "moon"}
)
```
This change will create additional branches that describe the data over time.
You may see the branch information by using the `Contract.explain` method.
The example above will create a total of three contracts:
- One for the original contract (spanning 1 year).
- One for the interval between original start and amended start.
- One for the interval between amended start and amended end.
The first contract will be disabled since it won't be relevant in after the
latest changes.
## Example
Jack is a farmer that sells eggs, and Janet is a baker that sells cakes (using
eggs, obviously). Jack and Janet make a contract in which Jack agrees to provide
Janet 10 eggs every day, for one year.
```python
contract = Contract.init(
start_at=datetime(2022, 12, 1),
end_at=datetime(2023, 12, 1),
data={"eggs_per_day": 10},
)
```
A couple of months pass, and Janet realizes that the easter is coming,
in which period cake requests are doubled. Now Janet needs 20 eggs per day,
instead of the usual 10. So a new agreement is made in which Janet would receive
20 eggs a day during the easter period:
```python
contract.branch(
start_at=datetime(2023, 4, 1),
end_at=datetime(2023, 5, 1),
data={"eggs_per_day": 20},
)
```
Shortly after the easter period, Janet sees an increase in sales thanks to the
delicious cakes she sold during the easter period. So she makes a new agreement
with Jack in which the number of eggs per day is increased to 15:
```python
contract.branch(
start_at=datetime(2023, 5, 16),
data={"eggs_per_day": 15},
)
```
Now let's look at what happened, output from `contract.gantt()`:
![Gannt chart](assets/example.png)
In the example above, each line represents a contract (hence a `Branch`instance)
you can track how the date changes by following blue lines. Red lines indicate
contracts that were replaced by newer ones (i.e., they are no longer relevant).
Raw data
{
"_id": null,
"home_page": "",
"name": "pcontract",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "contract,contract-management,data-tracking",
"author": "",
"author_email": "suayip uzulmez <suayip.541@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/27/e3/caeab8d647fd6ad7ebc8cceac1c274a9fd84532a09686425f5c7aa32c0df/pcontract-1.0.0.tar.gz",
"platform": null,
"description": "# pcontract\n\nA data structure to track data over time. It works by tracking time/schedule\ninformation **rather than tracking data changes** over time.\n\n\n## Reasoning\n\nLet's assume you make a contract with a person (in this example,\nassume it's a lease agreement). In the first draft, the parties agree on\nsome conditions, and if they are happy, they close the deal.\n\nNow, assume after some time, one of the parties need to amend some\nchanges, (after the fact that the contract was in place), in which case the\noriginal contract would be nulled and a new contract would be drafted.\nThis new contract now spans a different time period and the conditions are\nchanged.\n\nIn this case the tenant would have held of the leased place for some time\n(say a month) until the amended contract was in place.\n\nTo account for this interval, amended contract could be drafted so that it would\nencompass the past month.\n\nHowever, the world of leasing is not perfect and sometimes one of the parties\nwill need to pursue this one-month interval according to the original contract\n(e.g., the landlord increased the rent, but it will become effective in the\ncoming month). In such a case, there needs to be a contract for the one-month\ninterval since the original contract spans more than that.\n\nAs such, we need a way to create contracts and amend them without having to\nthink about these intervals; things get more complex if the amending is not\npermanent but transitory (e.g., effective only for some limited time during\nthe original contract).\n\n## How it works\n\nIn order to create a contract, you need to use a `Contract` type, which is a\ncontainer for `Branch` i.e, contracts. You may initialize a basic contract by:\n\n```python\ncontract = Contract.init(\n start_at=datetime(2022, 12, 1),\n end_at=datetime(2023, 12, 1),\n data={\"hello\": \"world\"},\n)\n```\n\nThe example above creates a contract that spans one year, with given data. In\norder to amend a contract, you may use `Contract.branch`:\n\n```\ncontract.branch(\n start_at=datetime(2023, 6, 1),\n data={\"hello\": \"moon\"}\n)\n```\n\nThis change will create additional branches that describe the data over time.\nYou may see the branch information by using the `Contract.explain` method.\nThe example above will create a total of three contracts:\n\n- One for the original contract (spanning 1 year).\n- One for the interval between original start and amended start.\n- One for the interval between amended start and amended end.\n\nThe first contract will be disabled since it won't be relevant in after the\nlatest changes.\n\n\n## Example\n\nJack is a farmer that sells eggs, and Janet is a baker that sells cakes (using\neggs, obviously). Jack and Janet make a contract in which Jack agrees to provide\nJanet 10 eggs every day, for one year.\n\n```python\ncontract = Contract.init(\n start_at=datetime(2022, 12, 1),\n end_at=datetime(2023, 12, 1),\n data={\"eggs_per_day\": 10},\n)\n```\n\nA couple of months pass, and Janet realizes that the easter is coming,\nin which period cake requests are doubled. Now Janet needs 20 eggs per day,\ninstead of the usual 10. So a new agreement is made in which Janet would receive\n20 eggs a day during the easter period:\n\n```python\ncontract.branch(\n start_at=datetime(2023, 4, 1),\n end_at=datetime(2023, 5, 1),\n data={\"eggs_per_day\": 20},\n)\n```\n\nShortly after the easter period, Janet sees an increase in sales thanks to the\ndelicious cakes she sold during the easter period. So she makes a new agreement\nwith Jack in which the number of eggs per day is increased to 15:\n\n```python\ncontract.branch(\n start_at=datetime(2023, 5, 16),\n data={\"eggs_per_day\": 15},\n)\n```\n\nNow let's look at what happened, output from `contract.gantt()`:\n\n![Gannt chart](assets/example.png)\n\nIn the example above, each line represents a contract (hence a `Branch`instance)\nyou can track how the date changes by following blue lines. Red lines indicate\ncontracts that were replaced by newer ones (i.e., they are no longer relevant).\n",
"bugtrack_url": null,
"license": "Copyright (c) 2022, \u015euayip \u00dcz\u00fclmez All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
"summary": "A data structure to track data over time.",
"version": "1.0.0",
"project_urls": {
"Bug Tracker": "https://github.com/realsuayip/pcontract/issues",
"Homepage": "https://github.com/realsuayip/pcontract"
},
"split_keywords": [
"contract",
"contract-management",
"data-tracking"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fe2a836016d358809af3ba329458da6caad2b968df5dd94e1ade1d58bd345785",
"md5": "c96850e1e5dfee64993c6f7cd30ffb26",
"sha256": "28ae6a8b4c1c95b75355eba33d339dcf31fa1ae6e79403a061c8976fcf6336de"
},
"downloads": -1,
"filename": "pcontract-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c96850e1e5dfee64993c6f7cd30ffb26",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9983,
"upload_time": "2024-01-19T20:30:18",
"upload_time_iso_8601": "2024-01-19T20:30:18.941750Z",
"url": "https://files.pythonhosted.org/packages/fe/2a/836016d358809af3ba329458da6caad2b968df5dd94e1ade1d58bd345785/pcontract-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "27e3caeab8d647fd6ad7ebc8cceac1c274a9fd84532a09686425f5c7aa32c0df",
"md5": "e35739e0ce427905f0849f53d664cdf5",
"sha256": "e57adafe5f27ddfcdb8e069b0e83559ecf41525d992f90b7182d5eddafa312b2"
},
"downloads": -1,
"filename": "pcontract-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "e35739e0ce427905f0849f53d664cdf5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 44944,
"upload_time": "2024-01-19T20:30:21",
"upload_time_iso_8601": "2024-01-19T20:30:21.046697Z",
"url": "https://files.pythonhosted.org/packages/27/e3/caeab8d647fd6ad7ebc8cceac1c274a9fd84532a09686425f5c7aa32c0df/pcontract-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-19 20:30:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "realsuayip",
"github_project": "pcontract",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pcontract"
}