cs.delta


Namecs.delta JSON
Version 20240316 PyPI version JSON
download
home_page
SummaryUtility functions around state changes.
upload_time2024-03-16 07:02:00
maintainer
docs_urlNone
author
requires_python
licenseGNU General Public License v3 or later (GPLv3+)
keywords python2 python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Utility functions around state changes.

*Latest release 20240316*:
Fixed release upload artifacts.

## 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=None)`

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 mapping
* `keys`: an optional iterable of keys of interest;
  if omitted, all the old and new mapping keys are examined
* `ifunchanged`: optional flag, default `False`;
  if true yield a tuple on every poll instead of only when a
  state change is seen
* `interval`: an optional interpoll `time.sleep` period,
  default `0.3`s
* `runstate`: an optional `RunState`, whose `cancelled`
  attribute will be polled for loop termination

# Release Log



*Release 20240316*:
Fixed release upload artifacts.

*Release 20240214*:
Initial PyPI release.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cs.delta",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python2,python3",
    "author": "",
    "author_email": "Cameron Simpson <cs@cskk.id.au>",
    "download_url": "https://files.pythonhosted.org/packages/c7/1a/13c9e4bc634bc81c6cecdef57a3a1b129e7d324c6d81e9eb2c9d8c7f9f12/cs.delta-20240316.tar.gz",
    "platform": null,
    "description": "Utility functions around state changes.\n\n*Latest release 20240316*:\nFixed release upload artifacts.\n\n## Function `delta(old, new, keys=None)`\n\nReturn a mapping representing differences between the mappings\n`old` and `new` for the specified `keys`.\nIf `keys` is not specified, the union of the keys of `old`\nand `new` is used.\n\nThe returned mapping has a key for each changed value.\nIf the key does not exist in `new` the value is the `MISSING`\nsentinel object otherwise it is `new[key]`.\nValues are compared using `==`; if that raises `TypeError`\nthe values are considered not equal.\n\nExample:\n\n  >>> d1 = {1: 2, 3: 4, 5: 6}\n  >>> d2 = {1: 2, 3: 44, 7: 8}\n  >>> diff = delta(d1, d2)\n  >>> diff  # doctest: +ELLIPSIS\n  {3: 44, 5: <object object at ...>, 7: 8}\n  >>> diff[5] is MISSING\n  True\n\n## Function `monitor(get_state, keys=None, *, ifunchanged=False, interval=0.3, runstate=None)`\n\nA generator yielding 3-tuples of `(old,new,delta(old,new,keys))`\nat poll intervals of `interval` seconds.\n\nParameters:\n* `get_state`: a callable which polls the current state,\n  returning a mapping\n* `keys`: an optional iterable of keys of interest;\n  if omitted, all the old and new mapping keys are examined\n* `ifunchanged`: optional flag, default `False`;\n  if true yield a tuple on every poll instead of only when a\n  state change is seen\n* `interval`: an optional interpoll `time.sleep` period,\n  default `0.3`s\n* `runstate`: an optional `RunState`, whose `cancelled`\n  attribute will be polled for loop termination\n\n# Release Log\n\n\n\n*Release 20240316*:\nFixed release upload artifacts.\n\n*Release 20240214*:\nInitial PyPI release.\n\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 or later (GPLv3+)",
    "summary": "Utility functions around state changes.",
    "version": "20240316",
    "project_urls": {
        "URL": "https://bitbucket.org/cameron_simpson/css/commits/all"
    },
    "split_keywords": [
        "python2",
        "python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9d0ce387add470fba87c02bf4d94b92ed089c7b5be7d03d1c56035dd0edd402",
                "md5": "92b53bb0a2d427ece30920033adc04de",
                "sha256": "0a8abcc6802c2e2cb2d390baccd1a53df722aa5a58f2e52e3d4de88f21057efc"
            },
            "downloads": -1,
            "filename": "cs.delta-20240316-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "92b53bb0a2d427ece30920033adc04de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3536,
            "upload_time": "2024-03-16T07:01:50",
            "upload_time_iso_8601": "2024-03-16T07:01:50.184898Z",
            "url": "https://files.pythonhosted.org/packages/f9/d0/ce387add470fba87c02bf4d94b92ed089c7b5be7d03d1c56035dd0edd402/cs.delta-20240316-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c71a13c9e4bc634bc81c6cecdef57a3a1b129e7d324c6d81e9eb2c9d8c7f9f12",
                "md5": "d4fbcbf3f22a5a1520e11793ffaab3f5",
                "sha256": "27eb7f117f0b65925c2dbf44bb887e644dac0efb921b1001d5b2b8fa2bae5580"
            },
            "downloads": -1,
            "filename": "cs.delta-20240316.tar.gz",
            "has_sig": false,
            "md5_digest": "d4fbcbf3f22a5a1520e11793ffaab3f5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3212,
            "upload_time": "2024-03-16T07:02:00",
            "upload_time_iso_8601": "2024-03-16T07:02:00.369555Z",
            "url": "https://files.pythonhosted.org/packages/c7/1a/13c9e4bc634bc81c6cecdef57a3a1b129e7d324c6d81e9eb2c9d8c7f9f12/cs.delta-20240316.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-16 07:02:00",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "cameron_simpson",
    "bitbucket_project": "css",
    "lcname": "cs.delta"
}
        
Elapsed time: 0.21254s