SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

 
 

python-dm.reuse rpm build for : openSUSE Leap 42. For other distributions click python-dm.reuse.

Name : python-dm.reuse
Version : 1.1 Vendor : obs://build_opensuse_org/devel:languages:python
Release : 2.6 Date : 2017-09-19 12:41:19
Group : Development/Languages/Python Source RPM : python-dm.reuse-1.1-2.6.src.rpm
Size : 0.02 MB
Packager : (none)
Summary : Support for object reuse with slight modifications
Description :
dm.reuse
========

Utilities to reuse (slightly modified) objects in new contexts.

Currently, there is a single utility: `rebindFunction`.
It allows to reuse the code of a function while changing name, globals,
default arguments, properties and/or names used.

Lets look at a trivial example. Function `f` accesses global variables
`i` and `j`.

Examples
--------

>>> i = 1; j = 2
>>> def f(): return i, j
...
>>> f()
(1, 2)

We want to derive a new function `g` which binds `i` to `-1`:

>>> from dm.reuse import rebindFunction
>>> g=rebindFunction(f, i=-1)
>>> g()
(-1, 2)

We can specify the rebinds not only via keyword arguments but via
a dictionary as well:

>>> g=rebindFunction(f, dict(i=-1, j=-2))
>>> g()
(-1, -2)

Usually, the function name is taken over from the original function,
but it can be changed:

>>> f.func_name
\'f\'
>>> g.func_name
\'f\'
>>> g=rebindFunction(f, dict(i=-1, j=-2), funcName=\'g\')
>>> g.func_name
\'g\'
>>> g()
(-1, -2)

The originals function docstring is taken over, too -- unless
overridden:

>>> f.func_doc = \'some documentation\'
>>> g=rebindFunction(f, dict(i=-1, j=-2))
>>> f.__doc__ is g.__doc__
True
>>> g=rebindFunction(f, dict(i=-1, j=-2), funcDoc=\'some new documentation\')
>>> g.__doc__
\'some new documentation\'

Default values for arguments can be added, removed or changed.
Unknown arguments are recognized:

>>> def f(a1, a2=2): return a1, a2
...
>>> g=rebindFunction(f, argRebindDir=dict(a1=1))
>>> g()
(1, 2)

>>> from dm.reuse import REQUIRED
>>> g=rebindFunction(f, argRebindDir=dict(a2=REQUIRED))
>>> g(1)
Traceback (most recent call last):
...
TypeError: f() takes exactly 2 arguments (1 given)

>>> g=rebindFunction(f, argRebindDir=dict(a2=10))
>>> g(1)
(1, 10)

>>> g=rebindFunction(f, argRebindDir=dict(a3=10))
Traceback (most recent call last):
...
ValueError: unknown arguments in `argRebindDir`: a3

Finally, function properties can be rebound with `propRebindDir`.
We are careful, to give the new function a separate new property dict.

>>> f.prop=\'p\'
>>> g=rebindFunction(f)
>>> g.prop
\'p\'
>>> g=rebindFunction(f, propRebindDir=dict(prop=\'P\', prop2=\'p2\'))
>>> g.prop, g.prop2
(\'P\', \'p2\')
>>> f.__dict__
{\'prop\': \'p\'}

Occationally, functions use local imports which are not adequate
in the new context. In order to provide control over them, names
used inside the function code can be changed.

>>> def f(a): import codecs; return codecs, a
...
>>> g=rebindFunction(f, nameRebindDir=dict(codecs=\'urllib\'))
>>> r = g(1)
>>> r[0].__name__, r[1]
(\'urllib\', 1)


History
-------

1.1
``nameRebindDir`` support added

RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/python/openSUSE_Leap_42.2/noarch

Content of RPM  Changelog  Provides Requires

Hmm ... It's impossible ;-) This RPM doesn't exist on any FTP server

Provides :
python-dm.reuse

Requires :
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
python(abi) = 2.7
rpmlib(PayloadIsLzma) <= 4.4.6-1


Content of RPM :
/usr/lib/python2.7/site-packages/dm
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7-nspkg.pth
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info/PKG-INFO
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info/SOURCES.txt
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info/dependency_links.txt
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info/namespace_packages.txt
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info/top_level.txt
/usr/lib/python2.7/site-packages/dm.reuse-1.1-py2.7.egg-info/zip-safe
/usr/lib/python2.7/site-packages/dm/reuse
/usr/lib/python2.7/site-packages/dm/reuse/LICENSE.txt
/usr/lib/python2.7/site-packages/dm/reuse/README.txt
/usr/lib/python2.7/site-packages/dm/reuse/VERSION.txt
/usr/lib/python2.7/site-packages/dm/reuse/__init__.py
/usr/lib/python2.7/site-packages/dm/reuse/__init__.pyc
/usr/lib/python2.7/site-packages/dm/reuse/tests.py
/usr/lib/python2.7/site-packages/dm/reuse/tests.pyc

 
ICM