Utility functions around state changes.
Latest release 20240622: Changes to accomodate dropping BaseCommandOptions.runstate.
Function delta(old, new, keys=None)
Return a mapping representing differences between the mappings
old and new for the specified keys.
If keys is not specified, the union of the keys of old
and new is used.
The returned mapping has a key for each changed value.
If the key does not exist in new the value is the MISSING
sentinel object otherwise it is new[key].
Values are compared using ==; if that raises TypeError
the values are considered not equal.
Example:
d1 = {1: 2, 3: 4, 5: 6} d2 = {1: 2, 3: 44, 7: 8} diff = delta(d1, d2) diff # doctest: +ELLIPSIS {3: 44, 5: <object object at ...>, 7: 8} diff[5] is MISSING True
Function monitor(get_state, keys=None, *, ifunchanged=False, interval=0.3, runstate: Optional[cs.resources.RunState] = <function uses_runstate.<locals>.<lambda> at 0x1072e81f0>)
A generator yielding 3-tuples of (old,new,delta(old,new,keys))
at poll intervals of interval seconds.
Parameters:
get_state: a callable which polls the current state, returning a mappingkeys: an optional iterable of keys of interest; if omitted, all the old and new mapping keys are examinedifunchanged: optional flag, defaultFalse; if true yield a tuple on every poll instead of only when a state change is seeninterval: an optional interpolltime.sleepperiod, default0.3srunstate: an optionalRunState, whosecancelledattribute will be polled for loop termination
Release Log
Release 20240622: Changes to accomodate dropping BaseCommandOptions.runstate.
Release 20240316: Fixed release upload artifacts.
Release 20240214: Initial PyPI release.
Release files for cs.delta 20240622
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cs.delta-20240622.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cs.delta-20240622-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / cs.delta-20240622.tar.gz
| Download URL | cs.delta-20240622.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1611f0027b954d39412caae87e2075996727948e770bcee86eb0b197b8b665df
|
|
BLAKE2b-256 checksum How to use checksums |
a2476dc89b36b64bc7d8522e46bfecd2ba815fa7a2420d59f72e8e95005bc99b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.6
|
Release files / cs.delta-20240622-py3-none-any.whl
| Download URL | cs.delta-20240622-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6add845557e1280f0246406eb6a66c30cf67c1dfa29ed0e375c46688418950fc
|
|
BLAKE2b-256 checksum How to use checksums |
783543833ba1260d305d0c0a14310b79a78ee695ffa9287befa96a38095a2fe1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.6
|