예제 #1
0
 def toterminal(self, tw: TerminalWriter, indent="") -> None:
     for line in self.lines:
         tw.line(indent + line)
 def toterminal(self, out: TerminalWriter) -> None:
     out.line(self.longrepr, red=True)
예제 #3
0
 def toterminal(self, tw: TerminalWriter) -> None:
     for reprlocation, lines in self.reprlocation_lines:
         for line in lines:
             tw.line(line)
         reprlocation.toterminal(tw)
예제 #4
0
def cacheshow(config: Config, session: Session) -> int:
    from pprint import pformat

    assert config.cache is not None

    tw = TerminalWriter()
    tw.line("cachedir: " + str(config.cache._cachedir))
    if not config.cache._cachedir.is_dir():
        tw.line("cache is empty")
        return 0

    glob = config.option.cacheshow[0]
    if glob is None:
        glob = "*"

    dummy = object()
    basedir = config.cache._cachedir
    vdir = basedir / Cache._CACHE_PREFIX_VALUES
    tw.sep("-", "cache values for %r" % glob)
    for valpath in sorted(x for x in vdir.rglob(glob) if x.is_file()):
        key = str(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 / Cache._CACHE_PREFIX_DIRS
    if ddir.is_dir():
        contents = sorted(ddir.rglob(glob))
        tw.sep("-", "cache directories for %r" % glob)
        for p in contents:
            # if p.check(dir=1):
            #    print("%s/" % p.relto(basedir))
            if p.is_file():
                key = str(p.relative_to(basedir))
                tw.line(f"{key} is a file of length {p.stat().st_size:d}")
    return 0
예제 #5
0
 def toterminal(self, tw: TerminalWriter) -> None:
     tw.line("я")
 def toterminal(self, tw: TerminalWriter) -> None:
     for name, content, sep in self.sections:
         tw.sep(sep, name)
         tw.line(content)