cs.py.func


Namecs.py.func JSON
Version 20230331 PyPI version JSON
download
home_pagehttps://bitbucket.org/cameron_simpson/css/commits/all
SummaryConvenience facilities related to Python functions.
upload_time2023-03-31 10:08:54
maintainer
docs_urlNone
authorCameron Simpson
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.
            Convenience facilities related to Python functions.

*Latest release 20230331*:
Drop @trace, moved to cs.debug.

## Function `callif(doit, func, *a, **kw)`

Call `func(*a,**kw)` if `doit` is true
otherwise just print it out.

The parameter `func` may be preceeded optionally by a `dict`
containing modes. The current modes are:
* `'print'`: the print function, default the builtin `print`

## Function `callmethod_if(o, method, default=None, a=None, kw=None)`

Call the named `method` on the object `o` if it exists.

If it does not exist, return `default` (which defaults to None).
Otherwise call getattr(o, method)(*a, **kw).
`a` defaults to ().
`kw` defaults to {}.

## Function `derived_from(property_name)`

A property which must be recomputed
if the revision of another property exceeds the snapshot revision.

## Function `derived_property(func, original_revision_name='_revision', lock_name='_lock', property_name=None, unset_object=None)`

A property which must be recomputed
if the reference revision (attached to self)
exceeds the snapshot revision.

## Function `func_a_kw(func, *a, **kw)`

Return a string representing a call to `func(*a,**kw)`.

## Function `func_a_kw_fmt(func, *a, **kw)`

Prepare a percent-format string and associated argument list
describing a call to `func(*a,**kw)`.
Return `format,args`.

The `func` argument can also be a string,
typically a prepared description of `func` such as `funccite(func)`.

*Note*: the returned `args` is a `list` for easy incorporation
into further arguments.  The `%` operator requires a `tuple`.

## Function `funccite(func)`

Return a citation for a function (name and code location).

## Function `funcname(func)`

Return a name for the supplied function `func`.
Several objects do not have a __name__ attribute, such as partials.

## Function `prop(func)`

A substitute for the builtin @property.

The builtin @property decorator lets internal AttributeErrors escape.
While that can support properties that appear to exist conditionally,
in practice this is almost never what I want, and it masks deeper errors.
Hence this wrapper for @property that transmutes internal AttributeErrors
into RuntimeErrors.

# Release Log



*Release 20230331*:
Drop @trace, moved to cs.debug.

*Release 20230210*:
Drop the returns_* and yields_* decorators, these days type annotations and @typechecked are the go.

*Release 20221207*:
* @trace: trace exceptions by default, previously false.
* Late import of cs.fs.shortpath to avoid import loop.
* New func_a_kw(func,*a,**kw) returning the formatted form of func_a_kw_fmt(func,*a,**kw).

*Release 20221118*:
@trace: add indenting.

*Release 20220619*:
@trace: rename some parameters, add with_caller.

*Release 20220311.1*:
New callif(doit[,modes],func,*a,**kw) to call or print a function, used in -n/--dry-run stuff sometimes.

*Release 20220311*:
* @trace: new pprint=False option to use pprint.pformat instead of repr for the return value.
* @trace: bugfix use of retval parameter.

*Release 20210913*:
New func_a_kw_fmt(func,*a,**kw) imported from cs.pfx, hooked it into @trace.

*Release 20210906*:
funcname: special case functools.partial, return concise name.

*Release 20210717*:
* Move @trace from debug to py.func, defer log call imports to avoid loops.
* Drop cs.pfx requirement, import opportunisticly with fallback.

*Release 20200518*:
funcname: prefer `func.__qualname__` over `func.__name__`

*Release 20190729*:
funccite: handle callables with no __code__ attribute.

*Release 20190108*:
Break import loop. Use cs.py3.raise_from for portability.

*Release 20181231*:
* Some type specific convenience wrappers for yields_type and returns_type.
* Bugfix for @prop.

*Release 20170906.1*:
Minor tweaks.

*Release 20170906*:
Bugfix for @prop.

*Release 20170608*:
New decorator @prop which works just like the builtin @property, but transmutes internal AttributeError into RuntimeError, unmasking many bugs.

*Release 20160828*:
Use "install_requires" instead of "requires" in DISTINFO.

*Release 20150115*:
First PyPI release.

            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/cameron_simpson/css/commits/all",
    "name": "cs.py.func",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python2,python3",
    "author": "Cameron Simpson",
    "author_email": "Cameron Simpson <cs@cskk.id.au>",
    "download_url": "https://files.pythonhosted.org/packages/e2/11/f3a7e77678e19ecaca5ec689c619a07440a25d79b8b4183571eaf4498915/cs.py.func-20230331.tar.gz",
    "platform": null,
    "description": "Convenience facilities related to Python functions.\n\n*Latest release 20230331*:\nDrop @trace, moved to cs.debug.\n\n## Function `callif(doit, func, *a, **kw)`\n\nCall `func(*a,**kw)` if `doit` is true\notherwise just print it out.\n\nThe parameter `func` may be preceeded optionally by a `dict`\ncontaining modes. The current modes are:\n* `'print'`: the print function, default the builtin `print`\n\n## Function `callmethod_if(o, method, default=None, a=None, kw=None)`\n\nCall the named `method` on the object `o` if it exists.\n\nIf it does not exist, return `default` (which defaults to None).\nOtherwise call getattr(o, method)(*a, **kw).\n`a` defaults to ().\n`kw` defaults to {}.\n\n## Function `derived_from(property_name)`\n\nA property which must be recomputed\nif the revision of another property exceeds the snapshot revision.\n\n## Function `derived_property(func, original_revision_name='_revision', lock_name='_lock', property_name=None, unset_object=None)`\n\nA property which must be recomputed\nif the reference revision (attached to self)\nexceeds the snapshot revision.\n\n## Function `func_a_kw(func, *a, **kw)`\n\nReturn a string representing a call to `func(*a,**kw)`.\n\n## Function `func_a_kw_fmt(func, *a, **kw)`\n\nPrepare a percent-format string and associated argument list\ndescribing a call to `func(*a,**kw)`.\nReturn `format,args`.\n\nThe `func` argument can also be a string,\ntypically a prepared description of `func` such as `funccite(func)`.\n\n*Note*: the returned `args` is a `list` for easy incorporation\ninto further arguments.  The `%` operator requires a `tuple`.\n\n## Function `funccite(func)`\n\nReturn a citation for a function (name and code location).\n\n## Function `funcname(func)`\n\nReturn a name for the supplied function `func`.\nSeveral objects do not have a __name__ attribute, such as partials.\n\n## Function `prop(func)`\n\nA substitute for the builtin @property.\n\nThe builtin @property decorator lets internal AttributeErrors escape.\nWhile that can support properties that appear to exist conditionally,\nin practice this is almost never what I want, and it masks deeper errors.\nHence this wrapper for @property that transmutes internal AttributeErrors\ninto RuntimeErrors.\n\n# Release Log\n\n\n\n*Release 20230331*:\nDrop @trace, moved to cs.debug.\n\n*Release 20230210*:\nDrop the returns_* and yields_* decorators, these days type annotations and @typechecked are the go.\n\n*Release 20221207*:\n* @trace: trace exceptions by default, previously false.\n* Late import of cs.fs.shortpath to avoid import loop.\n* New func_a_kw(func,*a,**kw) returning the formatted form of func_a_kw_fmt(func,*a,**kw).\n\n*Release 20221118*:\n@trace: add indenting.\n\n*Release 20220619*:\n@trace: rename some parameters, add with_caller.\n\n*Release 20220311.1*:\nNew callif(doit[,modes],func,*a,**kw) to call or print a function, used in -n/--dry-run stuff sometimes.\n\n*Release 20220311*:\n* @trace: new pprint=False option to use pprint.pformat instead of repr for the return value.\n* @trace: bugfix use of retval parameter.\n\n*Release 20210913*:\nNew func_a_kw_fmt(func,*a,**kw) imported from cs.pfx, hooked it into @trace.\n\n*Release 20210906*:\nfuncname: special case functools.partial, return concise name.\n\n*Release 20210717*:\n* Move @trace from debug to py.func, defer log call imports to avoid loops.\n* Drop cs.pfx requirement, import opportunisticly with fallback.\n\n*Release 20200518*:\nfuncname: prefer `func.__qualname__` over `func.__name__`\n\n*Release 20190729*:\nfunccite: handle callables with no __code__ attribute.\n\n*Release 20190108*:\nBreak import loop. Use cs.py3.raise_from for portability.\n\n*Release 20181231*:\n* Some type specific convenience wrappers for yields_type and returns_type.\n* Bugfix for @prop.\n\n*Release 20170906.1*:\nMinor tweaks.\n\n*Release 20170906*:\nBugfix for @prop.\n\n*Release 20170608*:\nNew decorator @prop which works just like the builtin @property, but transmutes internal AttributeError into RuntimeError, unmasking many bugs.\n\n*Release 20160828*:\nUse \"install_requires\" instead of \"requires\" in DISTINFO.\n\n*Release 20150115*:\nFirst PyPI release.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 or later (GPLv3+)",
    "summary": "Convenience facilities related to Python functions.",
    "version": "20230331",
    "split_keywords": [
        "python2",
        "python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d675bacb28eb55322339392bb9e20bb679168695c220ea871ac1d01b4d201df4",
                "md5": "3e2562e73222550e56b50c2f4361dd0f",
                "sha256": "5af9cb925d2e4212ba81dc6ccf325850e03eb59539a44ad5579093edacd6ca04"
            },
            "downloads": -1,
            "filename": "cs.py.func-20230331-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e2562e73222550e56b50c2f4361dd0f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5282,
            "upload_time": "2023-03-31T10:08:53",
            "upload_time_iso_8601": "2023-03-31T10:08:53.390794Z",
            "url": "https://files.pythonhosted.org/packages/d6/75/bacb28eb55322339392bb9e20bb679168695c220ea871ac1d01b4d201df4/cs.py.func-20230331-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e211f3a7e77678e19ecaca5ec689c619a07440a25d79b8b4183571eaf4498915",
                "md5": "4af41d3b3cbd78d53f162145446052dd",
                "sha256": "1204bf346bd580a504d4b093ae9ed8275edd54e4f6552d4ba714c85493d57ab8"
            },
            "downloads": -1,
            "filename": "cs.py.func-20230331.tar.gz",
            "has_sig": false,
            "md5_digest": "4af41d3b3cbd78d53f162145446052dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5118,
            "upload_time": "2023-03-31T10:08:54",
            "upload_time_iso_8601": "2023-03-31T10:08:54.888344Z",
            "url": "https://files.pythonhosted.org/packages/e2/11/f3a7e77678e19ecaca5ec689c619a07440a25d79b8b4183571eaf4498915/cs.py.func-20230331.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-31 10:08:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "cs.py.func"
}
        
Elapsed time: 0.06011s