コード例 #1
0
def _path_to_locate():
    """Location of the locate command on most unixen"""
    homebrewed_findutils = makepath('/usr/local/Cellar/findutils/4.4.2/bin/')
    for basename in ('locate', 'glocate'):
        homebrewed_locate = homebrewed_findutils / basename
        if homebrewed_locate.isfile():
            return homebrewed_locate
    return '/usr/bin/locate'
コード例 #2
0
def get_freds(paths):
    if not paths:
        freds.purge_insubstial()
        result = freds.substantial()
    else:
        result = set()
        for path in paths:
            path = makepath(path)
            if path.isdir():
                result |= {p for p in path.files('fred*') if p[-1] != '~'}
            elif path.isfile() and path.name.startswith('fred'):
                result.add(path)
    return [pwd().relpathto(p) for p in result]
コード例 #3
0
def removable_contents(tarball):
    names = {n.split('/', 1)[0] for n in tarfile.open(tarball).getnames()}
    name_paths = [makepath(n) for n in names]
    return [p for p in name_paths if p.isfile() or p.isdir()]
コード例 #4
0
def find_tarballs(args):
    arg_paths = [makepath(a) for a in args]
    tarballs = [p for p in arg_paths if is_tarball(p)]
    tarballs.extend(directory_tarballs(arg_paths))
    return tarballs