blob: e37b9111d86c6fce1e913955d06bf45a7b71a70d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/python
from debian_bundle import deb822
from gzip import GzipFile
from fnmatch import fnmatch
import sys
import patchtracker.Conf as Conf
if __name__ == '__main__':
try:
(prog,src,dst) = sys.argv
except ValueError:
print "usage: program <src> <dst>"
sys.exit(1)
inf = sys.argv[1]
fh = None
slist = []
if fnmatch(inf, "*.gz") or Conf.archive_lists_compressed:
fh = GzipFile(inf)
else:
fh = file(inf)
# temp workaround for #538376
if Conf.use_apt_pkg is not None:
slist = deb822.Sources.iter_paragraphs(fh, use_apt_pkg=Conf.use_apt_pkg)
else:
slist = deb822.Sources.iter_paragraphs(fh)
outf = file(sys.argv[2], "w")
print "filtering %s for .diff.gz/.dsc files..."%(inf)
for ent in slist:
for k in ['Files','Checksums-Sha1','Checksums-Sha256']:
newfiles = []
if ent.has_key(k):
for f in ent[k]:
if fnmatch(f['name'], '*.diff.gz') or fnmatch(f['name'], '*.dsc'):
newfiles.append(f)
ent[k] = newfiles
outf.write(str(ent))
outf.write("\n")
|