def cacheshow(config, session):
    from pprint import pformat
    tw = py.io.TerminalWriter()
    tw.line(('cachedir: ' + str(config.cache._cachedir)))
    if (not config.cache._cachedir.is_dir()):
        tw.line('cache is empty')
        return 0
    dummy = object()
    basedir = config.cache._cachedir
    vdir = (basedir / 'v')
    tw.sep('-', 'cache values')
    for valpath in sorted((x for x in vdir.rglob('*') if x.is_file())):
        key = valpath.relative_to(vdir)
        val = config.cache.get(key, dummy)
        if (val is dummy):
            tw.line(('%s contains unreadable content, will be ignored' % key))
        else:
            tw.line(('%s contains:' % key))
            for line in pformat(val).splitlines():
                tw.line(('  ' + line))
    ddir = (basedir / 'd')
    if ddir.is_dir():
        contents = sorted(ddir.rglob('*'))
        tw.sep('-', 'cache directories')
        for p in contents:
            if p.is_file():
                key = p.relative_to(basedir)
                tw.line('{} is a file of length {:d}'.format(key, p.stat().st_size))
    return 0
def cacheshow(config, session):
    from pprint import pformat
    tw = py.io.TerminalWriter()
    tw.line(('cachedir: ' + str(config.cache._cachedir)))
    if (not config.cache._cachedir.is_dir()):
        tw.line('cache is empty')
        return 0
    dummy = object()
    basedir = config.cache._cachedir
    vdir = (basedir / 'v')
    tw.sep('-', 'cache values')
    for valpath in sorted((x for x in vdir.rglob('*') if x.is_file())):
        key = valpath.relative_to(vdir)
        val = config.cache.get(key, dummy)
        if (val is dummy):
            tw.line(('%s contains unreadable content, will be ignored' % key))
        else:
            tw.line(('%s contains:' % key))
            for line in pformat(val).splitlines():
                tw.line(('  ' + line))
    ddir = (basedir / 'd')
    if ddir.is_dir():
        contents = sorted(ddir.rglob('*'))
        tw.sep('-', 'cache directories')
        for p in contents:
            if p.is_file():
                key = p.relative_to(basedir)
                tw.line('{} is a file of length {:d}'.format(key, p.stat().st_size))
    return 0