Example #1
0
def main():
    from optparse import OptionParser
    import store.indexed as indexed
    from egg_meta import is_valid_eggname

    p = OptionParser(usage="usage: %prog [options] ROOT_URL [EGG ...]", description="simple interface to fetch eggs")
    p.add_option("--auth", action="store", help="username:password")
    p.add_option("--dst", action="store", help="destination directory", default=os.getcwd(), metavar="PATH")
    p.add_option("--force", action="store_true")
    p.add_option("-v", "--verbose", action="store_true")

    opts, args = p.parse_args()

    if len(args) < 1:
        p.error("at least one argument (the repo root URL) expected, try -h")

    repo_url = args[0]
    if repo_url.startswith(("http://", "https://")):
        store = indexed.RemoteHTTPIndexedStore(repo_url)
    else:
        store = indexed.LocalIndexedStore(repo_url)

    store.connect(tuple(opts.auth.split(":", 1)) if opts.auth else None)

    f = FetchAPI(store, opts.dst)
    f.verbose = opts.verbose
    for fn in args[1:]:
        if not is_valid_eggname(fn):
            raise Exception("Error: invalid egg name: %r" % fn)
        f.fetch_egg(fn, opts.force)
Example #2
0
def parse_list(fn):
    pat = re.compile(r"([\w.]+)\s+([\w.]+-\d+)")
    res = set()
    for line in open(fn):
        line = line.strip()
        m = pat.match(line)
        if m:
            res.add(m.expand(r"\1-\2.egg"))
            continue
        if is_valid_eggname(line):
            res.add(line)
    return res
Example #3
0
 def calculate_all_patches():
     egg_names = [fn for fn in os.listdir(eggs_dir) if is_valid_eggname(fn)]
     names = set(split_eggname(egg_name)[0] for egg_name in egg_names)
     for name in sorted(names, key=string.lower):
         versions = []
         for egg_name in egg_names:
             n, v, b = split_eggname(egg_name)
             if n != name:
                 continue
             versions.append((v, b))
         versions.sort(key=(lambda vb: (comparable_version(vb[0]), vb[1])))
         versions = ["%s-%d" % vb for vb in versions]
         lv = len(versions)
         # print name, lv, versions
         for i in xrange(0, lv):
             for j in xrange(i + 1, lv):
                 yield "%s-%s--%s.zdiff" % (name, versions[i], versions[j])
Example #4
0
def req_from_anything(arg):
    if isinstance(arg, Req):
        return arg
    if is_valid_eggname(arg):
        return Req("%s %s-%d" % split_eggname(arg))
    return Req(arg)