Exemplo n.º 1
0
def nuke_nested_lists(store):
    c = store.get_cursor()
    c.execute("""select name, version, summary from releases
        where summary like '%nested lists%'""")
    hits = {}
    for name, version, summary in c.fetchall():
        for f in store.list_files(name, version):
            path = store.gen_file_path(f['python_version'], name, f['filename'])
            if path.endswith('.zip'):
                z = zipfile.ZipFile(path)
                for i in z.infolist():
                    if not i.filename.endswith('.py'): continue
                    if 'def print_lol' in z.read(i.filename):
                        hits[name] = summary
            elif path.endswith('.tar.gz'):
                z = gzip.GzipFile(path)
                t = tarfile.TarFile(fileobj=z)
                for i in t.getmembers():
                    if not i.name.endswith('.py'): continue
                    f = t.extractfile(i.name)
                    if 'def print_lol' in f.read():
                        hits[name] = summary
    for name in hits:
        store.remove_package(name)
        print '%s: %s' % (name, hits[name])
    print 'removed %d packages' % len(hits)
Exemplo n.º 2
0
def nuke_nested_lists(store, confirm=False):
    c = store.get_cursor()
    c.execute("""select name, version, summary from releases
        where lower(name) like '%nester%' or
        lower(summary) like '%nested lists%' or
        lower(summary) like '%geschachtelter listen%'""")
    hits = {}
    for name, version, summary in c.fetchall():
        if "printer of nested lists" in summary:
            hits[name] = summary
            continue
        if "Einfache Ausgabe geschachtelter Listen" in summary:
            hits[name] = summary
            continue
        for f in store.list_files(name, version):
            path = f['path']
            key = store.package_bucket.get_key(path)
            if key is None:
                print "PACKAGE %s FILE %s MISSING" % (name, path)
                continue
            contents = StringIO.StringIO(key.read())
            if path.endswith('.zip'):
                z = zipfile.ZipFile(contents)
                for i in z.infolist():
                    if not i.filename.endswith('.py'):
                        continue
                    src = z.read(i.filename)
                    if 'def print_lol' in src or 'def print_lvl' in src:
                        hits[name] = summary
            elif path.endswith('.tar.gz'):
                z = gzip.GzipFile(path, fileobj=contents)
                t = tarfile.TarFile(fileobj=z)
                for i in t.getmembers():
                    if not i.name.endswith('.py'): continue
                    f = t.extractfile(i.name)
                    src = f.read()
                    if 'def print_lol' in src or 'def print_lvl' in src:
                        hits[name] = summary
    for name in hits:
        if confirm:
            store.remove_package(name)
        print '%s: %s' % (name, hits[name])
    if confirm:
        print 'removed %d packages' % len(hits)
    else:
        print 'WOULD HAVE removed %d packages' % len(hits)
Exemplo n.º 3
0
def nuke_nested_lists(store, confirm=False):
    c = store.get_cursor()
    c.execute("""select name, version, summary from releases
        where lower(name) like '%nester%' or
        lower(summary) like '%nested lists%' or
        lower(summary) like '%geschachtelter listen%'""")
    hits = {}
    for name, version, summary in c.fetchall():
        if "printer of nested lists" in summary:
            hits[name] = summary
            continue
        if "Einfache Ausgabe geschachtelter Listen" in summary:
            hits[name] = summary
            continue
        for f in store.list_files(name, version):
            path = f['path']
            key = store.package_bucket.get_key(path)
            if key is None:
                print "PACKAGE %s FILE %s MISSING" % (name, path)
                continue
            contents = StringIO.StringIO(key.read())
            if path.endswith('.zip'):
                z = zipfile.ZipFile(contents)
                for i in z.infolist():
                    if not i.filename.endswith('.py'):
                        continue
                    src = z.read(i.filename)
                    if 'def print_lol' in src or 'def print_lvl' in src:
                        hits[name] = summary
            elif path.endswith('.tar.gz'):
                z = gzip.GzipFile(path, fileobj=contents)
                t = tarfile.TarFile(fileobj=z)
                for i in t.getmembers():
                    if not i.name.endswith('.py'): continue
                    f = t.extractfile(i.name)
                    src = f.read()
                    if 'def print_lol' in src or 'def print_lvl' in src:
                        hits[name] = summary
    for name in hits:
        if confirm:
            store.remove_package(name)
        print '%s: %s' % (name, hits[name])
    if confirm:
        print 'removed %d packages' % len(hits)
    else:
        print 'WOULD HAVE removed %d packages' % len(hits)