Exemplo n.º 1
0
class MockedPrint(object):
    def __init__(self):
        self.s = StringIO()

    def __call__(self, *a):
        self.s.write(" ".join(str(_) for _ in a) + "\n")

    @property
    def value(self):
        return self.s.getvalue()
Exemplo n.º 2
0
class MockedPrint(object):
    def __init__(self):
        self.s = StringIO()

    def __call__(self, *a):
        self.s.write(" ".join(str(_) for _ in a) + "\n")

    @property
    def value(self):
        return self.s.getvalue()
Exemplo n.º 3
0
def update_index(dir_path, force=False, verbose=False):
    """
    Updates index-depend.txt and index-depend.bz2 in the directory specified.
    If index-depend.txt already exists, its content (which contains
    modification time stamps) is used to create the updated file.
    This can be disabled using the force option.
    """
    txt_path = join(dir_path, 'index-depend.txt')
    if verbose:
        print("Updating:", txt_path)

    if force or not isfile(txt_path):
        section = {}
    else:
        section = parse_index(open(txt_path).read())

    # since generating the new data may take a while, we first write to memory
    # and then write the file afterwards.
    faux = StringIO()
    for fn in sorted(os.listdir(dir_path), key=string.lower):
        if not fn.endswith('.egg'):
            continue
        if not is_valid_eggname(fn):
            print("WARNING: ignoring invalid egg name:", fn)
            continue
        path = join(dir_path, fn)
        if fn in section:
            spec = parse_data(section[fn], index=True)
            if spec.get('mtime') == getmtime(path):
                faux.write('==> %s <==\n' % fn)
                faux.write(section[fn] + '\n')
                continue
        faux.write(index_section(path))
        if verbose:
            sys.stdout.write('.')
            sys.stdout.flush()

    if verbose:
        print()
    write_txt_bz2(txt_path, faux.getvalue())
    faux.close()

    import enstaller.egg_meta
    enstaller.egg_meta.update_index(dir_path, force, verbose)
Exemplo n.º 4
0
def update_index(dir_path, force=False, verbose=False):
    """
    Updates index-depend.txt and index-depend.bz2 in the directory specified.
    If index-depend.txt already exists, its content (which contains
    modification time stamps) is used to create the updated file.
    This can be disabled using the force option.
    """
    txt_path = join(dir_path, 'index-depend.txt')
    if verbose:
        print("Updating:", txt_path)

    if force or not isfile(txt_path):
        section = {}
    else:
        section = parse_index(open(txt_path).read())

    # since generating the new data may take a while, we first write to memory
    # and then write the file afterwards.
    faux = StringIO()
    for fn in sorted(os.listdir(dir_path), key=string.lower):
        if not fn.endswith('.egg'):
            continue
        if not is_valid_eggname(fn):
            print("WARNING: ignoring invalid egg name:", fn)
            continue
        path = join(dir_path, fn)
        if fn in section:
            spec = parse_data(section[fn], index=True)
            if spec.get('mtime') == getmtime(path):
                faux.write('==> %s <==\n' % fn)
                faux.write(section[fn] + '\n')
                continue
        faux.write(index_section(path))
        if verbose:
            sys.stdout.write('.')
            sys.stdout.flush()

    if verbose:
        print()
    write_txt_bz2(txt_path, faux.getvalue())
    faux.close()

    import enstaller.egg_meta
    enstaller.egg_meta.update_index(dir_path, force, verbose)