Exemplo n.º 1
0
def alltestnames(package_or_requirement, suite, regex=None): #{{{
    por = package_or_requirement
    if not regex:
        regex = _DefaultModNameRegex
    if ispackage(por, suite) or (isinstance(suite, basestring) and resource_isdir(por, suite)):
        return _atn_gen(por, suite, regex)
    raise TypeError('Cannot walk through sub packages/modules of %s object' %suite.__class__.__name__)
Exemplo n.º 2
0
def alltestobjects(package_or_requirement, suite, regex=None): #{{{
    por = package_or_requirement
    if not regex:
        regex = _DefaultModNameRegex
    if ispackage(por, suite) or (isinstance(suite, basestring) and resource_isdir(suite)):
        return _ato_gen(por, suite, regex)
    raise TypeError("%s object is not a package" %suite.__class__.__name__)
Exemplo n.º 3
0
def allrstfiles(package_or_requirement, dir): #{{{
    por = package_or_requirement
    if not resource_isdir(por, dir):
        raise OSError("No such directory: %s" %dir)
    for root, dirs, files in resource_walk(por, dir):
        for f in files:
            name, ext = op.splitext(f)
            if ext == '.rst':
                yield f
        return
Exemplo n.º 4
0
def isfilemodule(package_or_resource, obj): #{{{
    por, isfile = package_or_resource, resource_isfile
    try:
        assert ismodule(por, obj)
        name, ind = obj.__name__, 0
        if isinstance(por, basestring):
            ind = 1
        path = pp.join(pp.sep, *name.split('.')[ind:])
        check = []
        if resource_isdir(por, path):
            check.append(pp.join(path, '__init__'))
        check.append(path)
        ext = ['py'+c for c in ('', 'c', 'o')]
        assert any(isfile(por, '.'.join([p, pext])) for pext in ext for p in check)
    except AssertionError:
        return False
    return True