#!/usr/bin/python ## ## Simply reads in a changes file, and dumps a list of the files it lists ## ## If the changes filename is passed on the command line, the filenames are ## given the same parent path as the changes filename. ## ## If the contents of the changes file are given on stdin, the file pathnames ## are listed as is ## import os.path, sys import deb822 ## changes is a file object, dir is a string def dumpfiles(changes, dir): for f in changes.map["Files"].splitlines(True): ## skip the md5sum, size, section, etc - filename is last field fields = f.split() if len(fields) > 4: name = fields[4] else: continue sys.stdout.write(os.path.join(dir, name) + "\n") if __name__ == '__main__': if len(sys.argv) >= 2: for arg in sys.argv[1:]: changes = deb822.deb822(open(arg, 'r')) dir = os.path.dirname(arg) dumpfiles(changes, os.path.dirname(arg)) else: changes = deb822.deb822(sys.stdin) dumpfiles(changes, "")