# History Set #
A Set implementation that tracks added and removed elements.
## Usage ##
~~~python >>> from history_set import HistorySet >>> history_set = HistorySet([1, 2, 3]) >>> history_set.add(4) >>> history_set # Prints: {1, 2, 3, 4} >>> history_set.added() # Prints: {4} >>> history_set.remove(1) >>> history_set # Prints: {2, 3, 4} >>> history_set.removed() # Prints: {1} >>> history_set.reset() >>> history_set.added() # Prints: set() >>> history_set.removed() # Prints: set() ~~~
## Special case ##
By default, if an element is added and later removed, it will not be tracked in history
~~~python >>> history_set = HistorySet([1, 2, 3]) >>> history_set.add(4) >>> history_set.remove(4) >>> history_set.added() # Prints: set() >>> history_set.removed() # Prints: set() ~~~
If you require these elements to be tracked, you can construct the object with the eidetic keyword argument
~~~python >>> history_set = HistorySet([1, 2, 3], eidetic=True) >>> history_set.add(4) >>> history_set.remove(4) >>> history_set.added() # Prints: {4} >>> history_set.removed() # Prints: {4} ~~~
By default, the reset() method will clear the entire history
~~~python >>> history_set = HistorySet([1, 2, 3]) >>> history_set.add(4) >>> history_set.added() # Prints: {4} >>> history_set.remove(2) >>> history_set.removed() # Prints: {2} >>> history_set.reset() >>> history_set.added() # Prints: set() >>> history_set.removed() # Prints: set() ~~~
If you require reseting only the added() or removed() history, you can call the reset method with added or removed booleans values to specify which history you with to reset
~~~python >>> history_set = HistorySet([1, 2, 3]) >>> history_set.add(4) >>> history_set.added() # Prints: {4} >>> history_set.remove(2) >>> history_set.removed() # Prints: {2} >>> history_set.reset(added=True) >>> history_set.added() # Prints: set() >>> history_set.removed() # Prints: {2} ~~~
## Test ##
You can run the tests using [tox](https://tox.readthedocs.io/en/latest/)
~~~shell tox ~~~
## Publish ##
To publish a new version of this package your Pypi user needt to be added to the project. (Ask Tjaart to give you access)
~~~shell # Update version number in setup.py
python setup.py sdist twine upload dist/* ~~~
Metadata
Release files for history-set 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| history-set-0.3.0.tar.gz | 3.1 kB | Without provenance | Details for history-set-0.3.0.tar.gz |
Release files / history-set-0.3.0.tar.gz
| Download URL | history-set-0.3.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9fcb23654f5e1a1ff85a4de416e262a46ad3652e93278afd2b45b39425c7a4b
|
|
BLAKE2b-256 checksum How to use checksums |
c7b70154b939970e1520d9532d633cd348ef927afab4d8c02f5c145b08c5383b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.2
|
Security for history-set 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.