예제 #1
0
def __wrap_stage_dependencies__(cls):
    stage_depends = cls.stage_depends
    # we use id instead of the cls itself to prevent strong ref issues.
    cls_id = id(cls)
    for x in set(x for x in iflatten_instance(stage_depends.iteritems()) if x):
        try:
            f = getattr(cls, x)
        except AttributeError:
            raise TypeError("class %r stage_depends specifies "
                "%r, which doesn't exist" % (cls, x))
        f2 = pre_curry(_ensure_deps, cls_id, x, f)
        f2.sd_raw_func = f
        setattr(cls, x, f2)
예제 #2
0
def __wrap_stage_dependencies__(cls):
    stage_depends = cls.stage_depends
    # we use id instead of the cls itself to prevent strong ref issues.
    cls_id = id(cls)
    for x in set(x for x in iflatten_instance(stage_depends.iteritems()) if x):
        try:
            f = getattr(cls, x)
        except AttributeError:
            raise TypeError("class %r stage_depends specifies "
                            "%r, which doesn't exist" % (cls, x))
        f2 = pre_curry(_ensure_deps, cls_id, x, f)
        f2.sd_raw_func = f
        setattr(cls, x, f2)
예제 #3
0
파일: fs_util.py 프로젝트: ferringb/pkgcore
"""
WARNING: this module is for testing usage only; it disables
the default strictness tests that fsBase.* derivatives have to ease
testing.  Do not use it in non-test code.
"""

from pkgcore.fs import fs
# we use pre_curry to preserve the docs for the wrapped target
from snakeoil.currying import pre_curry

# we're anal about del'ing here to prevent the vars from lingering around,
# showing up when folks are poking around

key = None
for key in dir(fs):
    val = getattr(fs, key)
    # protection; issubclass pukes if it's not a class.
    # downside, this works on new style only
    if isinstance(val, type) and issubclass(val, fs.fsBase) and \
            val is not fs.fsBase:
        locals()[f"_original_{key}"] = val
        val = pre_curry(val, strict=False)
        val.__doc__ = locals()[f"_original_{key}"].__doc__
    locals()[key] = val
    del val

del key
예제 #4
0
파일: fs_util.py 프로젝트: den4ix/pkgcore
# License: GPL2/BSD

"""
WARNING: this module is for testing usage only; it disables
the default strictness tests that fsBase.* derivatives have to ease
testing.  Do not use it in non-test code.
"""

# we use pre_curry to preserve the docs for the wrapped target
from snakeoil.currying import pre_curry

from pkgcore.fs import fs

# we're anal about del'ing here to prevent the vars from lingering around,
# showing up when folks are poking around

key = None
for key in dir(fs):
    val = getattr(fs, key)
    # protection; issubclass pukes if it's not a class.
    # downside, this works on new style only
    if isinstance(val, type) and issubclass(val, fs.fsBase) and \
            val is not fs.fsBase:
        locals()["_original_%s" % key] = val
        val = pre_curry(val, strict=False)
        val.__doc__ = locals()["_original_%s" % key].__doc__
    locals()[key] = val
    del val

del key
예제 #5
0
 def f(func):
     return pre_curry(wrap_build_method, phase, func)
예제 #6
0
 class foo(target):
     for x in set(dir(target)).difference(dir(object)):
         locals()[x] = pre_curry(_reflection_func, x)
예제 #7
0
 def f(func):
     return pre_curry(wrap_build_method, phase, func)
예제 #8
0
 class kls(base_cls):
     __slots__ = ()
     locals().update((k, currying.pre_curry(_generic_immutable_method, k))
                     for k in ["write", "writelines", "truncate"])