def index_all_files(self, repo): """ Add all distributions to the index, see index_file() above. Note that no index file is written to disk. """ dir_path = dist_naming.dirname_repo(repo) assert isdir(dir_path), dir_path for fn in os.listdir(dir_path): if not fn.endswith('.egg'): continue if not dist_naming.is_valid_eggname(fn): print "WARNING: ignoring invalid egg name:", join(dir_path, fn) continue self.index_file(fn, repo)
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)
def update_index(dir_path, force=False, verbose=False): """ Updates index-depend.txt 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 faux.close()
def main(): from optparse import OptionParser p = OptionParser(usage="usage: %prog [options] REPO [EGG ...]", description="simple interface to fetch eggs") p.add_option("--dst", action="store", help="destination directory", default=os.getcwd(), metavar='PATH') p.add_option('-v', "--verbose", action="store_true") opts, args = p.parse_args() if len(args) < 1: p.error('at least one argument expected, try -h') repo = args[0] c = Chain([repo], opts.verbose) for fn in args[1:]: if not dist_naming.is_valid_eggname(fn): sys.exit('Error: invalid egg name: %r' % fn) c.fetch_dist(repo + fn, opts.dst)