5 #from debian_bundle import deb822
9 def check_source(ok, f, fw):
11 pkg = apt_pkg.ParseTagFile(f)
13 if not pkg.Section.get('Package'): continue
14 if pkg.Section.get('Section','').startswith('non-free'):
15 if pkg.Section.get('Autobuild') != 'yes': continue
16 if pkg.Section['Package'] not in ok: continue
17 ret += [pkg.Section['Package']]
18 fw.write(str(pkg.Section))
24 def check_binary(ok, f, fw):
25 pkg = apt_pkg.ParseTagFile(f)
27 if pkg.Section.get('Source', pkg.Section.get('Package')).split(" ")[0] not in ok: continue
28 fw.write(str(pkg.Section))
33 def outfile(name, file):
34 #return open(dir + "/" + os.path.basename(file), "w")
35 #return open(file + name, "w")
36 if file.endswith(name): return open(file[:-len(name)], "w")
39 if len(sys.argv) <= 4:
40 print "Error - too few args"
44 oklist = [ x[:-1].split(' ')[0] for x in open(sys.argv[2]) ]
45 okpkgs = check_source(oklist, open(sys.argv[3]), outfile(name, sys.argv[3]))
46 for file in sys.argv[4:]:
47 check_binary(okpkgs, open(file), outfile(name, file))
49 if __name__ == '__main__':