Name | cs-py-func JSON |
Version |
20250724
JSON |
| download |
home_page | None |
Summary | Convenience facilities related to Python functions. |
upload_time | 2025-07-24 01:31:58 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3 |
license | None |
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 20250724*:
* func_a_kw_fmt: shorten long %r, widen another field.
* Drop Python 2 support.
Short summary:
* `callif`: Call `func(*a,**kw)` if `doit` is true otherwise just print it out.
* `callmethod_if`: Call the named `method` on the object `obj` if it exists.
* `derived_from`: A property which must be recomputed if the revision of another property exceeds the snapshot revision.
* `derived_property`: A property which must be recomputed if the reference revision (attached to self) exceeds the snapshot revision.
* `func_a_kw`: Return a string representing a call to `func(*a,**kw)`.
* `func_a_kw_fmt`: Prepare a percent-format string and associated argument list describing a call to `func(*a,**kw)`. Return `format,args`.
* `funccite`: Return a citation for a function (name and code location).
* `funcname`: Return a name for the supplied function `func`. Several objects do not have a __name__ attribute, such as partials.
* `prop`: A substitute for the builtin @property.
Module contents:
- <a name="callif"></a>`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`
- <a name="callmethod_if"></a>`callmethod_if(obj, method, default=None, a=None, kw=None)`: Call the named `method` on the object `obj` if it exists.
If it does not exist, return `default` (which defaults to None).
Otherwise call getattr(obj, method)(*a, **kw).
`a` defaults to ().
`kw` defaults to {}.
- <a name="derived_from"></a>`derived_from(property_name)`: A property which must be recomputed
if the revision of another property exceeds the snapshot revision.
- <a name="derived_property"></a>`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.
- <a name="func_a_kw"></a>`func_a_kw(func, *a, **kw)`: Return a string representing a call to `func(*a,**kw)`.
- <a name="func_a_kw_fmt"></a>`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`.
- <a name="funccite"></a>`funccite(func)`: Return a citation for a function (name and code location).
- <a name="funcname"></a>`funcname(func)`: Return a name for the supplied function `func`.
Several objects do not have a __name__ attribute, such as partials.
- <a name="prop"></a>`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 20250724*:
* func_a_kw_fmt: shorten long %r, widen another field.
* Drop Python 2 support.
*Release 20240630*:
funcname: include the module name, handle functions with no __module__.
*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": null,
"name": "cs-py-func",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "python2, python3",
"author": null,
"author_email": "Cameron Simpson <cs@cskk.id.au>",
"download_url": "https://files.pythonhosted.org/packages/6f/27/6cdfa0985e5eff192ab280b8ad68f65e56edf419fc50edf3339e2ebcde85/cs_py_func-20250724.tar.gz",
"platform": null,
"description": "Convenience facilities related to Python functions.\n\n*Latest release 20250724*:\n* func_a_kw_fmt: shorten long %r, widen another field.\n* Drop Python 2 support.\n\nShort summary:\n* `callif`: Call `func(*a,**kw)` if `doit` is true otherwise just print it out.\n* `callmethod_if`: Call the named `method` on the object `obj` if it exists.\n* `derived_from`: A property which must be recomputed if the revision of another property exceeds the snapshot revision.\n* `derived_property`: A property which must be recomputed if the reference revision (attached to self) exceeds the snapshot revision.\n* `func_a_kw`: Return a string representing a call to `func(*a,**kw)`.\n* `func_a_kw_fmt`: Prepare a percent-format string and associated argument list describing a call to `func(*a,**kw)`. Return `format,args`.\n* `funccite`: Return a citation for a function (name and code location).\n* `funcname`: Return a name for the supplied function `func`. Several objects do not have a __name__ attribute, such as partials.\n* `prop`: A substitute for the builtin @property.\n\nModule contents:\n- <a name=\"callif\"></a>`callif(doit, func, *a, **kw)`: Call `func(*a,**kw)` if `doit` is true\n otherwise just print it out.\n\n The parameter `func` may be preceeded optionally by a `dict`\n containing modes. The current modes are:\n * `'print'`: the print function, default the builtin `print`\n- <a name=\"callmethod_if\"></a>`callmethod_if(obj, method, default=None, a=None, kw=None)`: Call the named `method` on the object `obj` if it exists.\n\n If it does not exist, return `default` (which defaults to None).\n Otherwise call getattr(obj, method)(*a, **kw).\n `a` defaults to ().\n `kw` defaults to {}.\n- <a name=\"derived_from\"></a>`derived_from(property_name)`: A property which must be recomputed\n if the revision of another property exceeds the snapshot revision.\n- <a name=\"derived_property\"></a>`derived_property(func, original_revision_name='_revision', lock_name='_lock', property_name=None, unset_object=None)`: A property which must be recomputed\n if the reference revision (attached to self)\n exceeds the snapshot revision.\n- <a name=\"func_a_kw\"></a>`func_a_kw(func, *a, **kw)`: Return a string representing a call to `func(*a,**kw)`.\n- <a name=\"func_a_kw_fmt\"></a>`func_a_kw_fmt(func, *a, **kw)`: Prepare a percent-format string and associated argument list\n describing a call to `func(*a,**kw)`.\n Return `format,args`.\n\n The `func` argument can also be a string,\n typically a prepared description of `func` such as `funccite(func)`.\n\n *Note*: the returned `args` is a `list` for easy incorporation\n into further arguments. The `%` operator requires a `tuple`.\n- <a name=\"funccite\"></a>`funccite(func)`: Return a citation for a function (name and code location).\n- <a name=\"funcname\"></a>`funcname(func)`: Return a name for the supplied function `func`.\n Several objects do not have a __name__ attribute, such as partials.\n- <a name=\"prop\"></a>`prop(func)`: A substitute for the builtin @property.\n\n The builtin @property decorator lets internal AttributeErrors escape.\n While that can support properties that appear to exist conditionally,\n in practice this is almost never what I want, and it masks deeper errors.\n Hence this wrapper for @property that transmutes internal AttributeErrors\n into RuntimeErrors.\n\n# Release Log\n\n\n\n*Release 20250724*:\n* func_a_kw_fmt: shorten long %r, widen another field.\n* Drop Python 2 support.\n\n*Release 20240630*:\nfuncname: include the module name, handle functions with no __module__.\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": null,
"summary": "Convenience facilities related to Python functions.",
"version": "20250724",
"project_urls": {
"MonoRepo Commits": "https://bitbucket.org/cameron_simpson/css/commits/branch/main",
"Monorepo Git Mirror": "https://github.com/cameron-simpson/css",
"Monorepo Hg/Mercurial Mirror": "https://hg.sr.ht/~cameron-simpson/css",
"Source": "https://github.com/cameron-simpson/css/blob/main/lib/python/cs/py/func.py"
},
"split_keywords": [
"python2",
" python3"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d40d0add19cc37dfcf4f69cbd3d8c31fe60d84c04e1c4d8a267ce74530e97d8f",
"md5": "e19e2ba1cc24b284b0248552ed7430e3",
"sha256": "dfa5901f1a8a61ef9f5dc9ce5ca82d145ad7158b5f233573738e27fa96be9cf0"
},
"downloads": -1,
"filename": "cs_py_func-20250724-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e19e2ba1cc24b284b0248552ed7430e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 5309,
"upload_time": "2025-07-24T01:31:57",
"upload_time_iso_8601": "2025-07-24T01:31:57.118389Z",
"url": "https://files.pythonhosted.org/packages/d4/0d/0add19cc37dfcf4f69cbd3d8c31fe60d84c04e1c4d8a267ce74530e97d8f/cs_py_func-20250724-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6f276cdfa0985e5eff192ab280b8ad68f65e56edf419fc50edf3339e2ebcde85",
"md5": "3c94afe556af0d418c50cd06660c12fa",
"sha256": "16cbcdd9296a9e3ea2a06211a2259aff85dfc0a9cb6d513caa8b985c17214ac3"
},
"downloads": -1,
"filename": "cs_py_func-20250724.tar.gz",
"has_sig": false,
"md5_digest": "3c94afe556af0d418c50cd06660c12fa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 4408,
"upload_time": "2025-07-24T01:31:58",
"upload_time_iso_8601": "2025-07-24T01:31:58.107088Z",
"url": "https://files.pythonhosted.org/packages/6f/27/6cdfa0985e5eff192ab280b8ad68f65e56edf419fc50edf3339e2ebcde85/cs_py_func-20250724.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-24 01:31:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cameron-simpson",
"github_project": "css",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "cs-py-func"
}