Example #1
0
def list_backups() -> None:
    """List all backups in the repository."""
    backups = g.repo.all_backups
    p = Pager()
    for b in backups:
        if not p.print(b):
            break
Example #2
0
def list_all_files() -> None:
    """List all files in the open backup.

    We really don't need this, since "list '*'" does the same thing.
    """
    if g.backup == NO_BKUP:
        util.msg("You must 'use' a backup first.")
    else:
        p = Pager()
        count = 0
        for f in g.repo.next_file(g.backup):
            count += 1
            if not p.print(normalize(f.fname)):
                break
        print('Files found:', count)
Example #3
0
def list_files(pattern: str, backup: str) -> None:
    """List files in 'backup' that match 'pattern'."""
    xpat = fnmatch.translate(pattern)
    try:
        pat = re.compile(xpat)
        count = 0
        p = Pager()
        for f in g.repo.next_file(backup):
            fname = normalize(f.fname)
            if pat.match(fname):
                if not p.print(fname):
                    break
                count += 1
        # print('Files found:', count)
    except re.error:
        util.error('Bad search pattern')
Example #4
0
def find_files(pattern: str) -> None:
    """Search all backups for files matching 'pattern'."""
    p = Pager()
    try:
        xpat = fnmatch.translate(pattern)
        pat = re.compile(xpat)
        stop = False
        for b in g.repo.all_backups:
            if not stop:
                for f in g.repo.next_file(b):
                    fname = normalize(f.fname)
                    if pat.match(fname):
                        mtime = time.ctime(float(f.mtime))
                        if not p.print(f'{b}\t{mtime}\t{fname}'):
                            stop = True
                            break
    except re.error:
        util.error('Bad search pattern')