def _atn_gen(por, suite, regex): #{{{ if not isinstance(regex, _REType): raise TypeError("%s object is not a compiled regular expression" %regex.__class__.__name__) topdir = pkg_dirname(por, suite) for dir, subdir, files in resource_walk(por, topdir): for f in files: name, ext = op.splitext(f) if ext == '.py' and regex.match(name): yield absmodpath(por, pp.join(topdir, f)) for d in subdir: path = pp.join(topdir, d) if hasinit(por, path) and regex.match(d): yield absmodpath(por, path) break
def pkg_dirname(por, obj): #{{{ if not ispackage(por, obj): return obj topdir, ind = '', 0 ppath = absmodpath(por, obj).split('.') if isinstance(por, basestring): ind = 1 topdir = pp.join(*ppath[ind:]) return topdir