3 # Copyright: 2015 The Debian Project
4 # License: MIT-License or Apache-2.0
6 # Helper to remove removed-files from .cargo-checksum
7 # TODO: rewrite to perl and add to dh-cargo, maybe?
9 from collections import OrderedDict
16 with open(".cargo-checksum.json") as fp:
17 sums = json.load(fp, object_pairs_hook=OrderedDict)
19 oldfiles = sums["files"]
20 newfiles = OrderedDict([entry for entry in oldfiles.items() if os.path.exists(entry[0])])
21 sums["files"] = newfiles
23 if len(oldfiles) > len(newfiles):
24 with open(".cargo-checksum.json", "w") as fp:
25 json.dump(sums, fp, separators=(',', ':'))
27 if __name__ == "__main__":
28 main(sys.argv[1] if len(sys.argv) > 1 else ".")