]> git.pld-linux.org Git - packages/cargo.git/blob - cargo-checksums-prune.py
add missing buildroot
[packages/cargo.git] / cargo-checksums-prune.py
1 #!/usr/bin/env python3
2
3 # Copyright: 2015 The Debian Project
4 # License: MIT-License or Apache-2.0
5 #
6 # Helper to remove removed-files from .cargo-checksum
7 # TODO: rewrite to perl and add to dh-cargo, maybe?
8
9 from collections import OrderedDict
10 import json
11 import os
12 import sys
13
14 def main(pkgdir):
15   os.chdir(pkgdir)
16   with open(".cargo-checksum.json") as fp:
17     sums = json.load(fp, object_pairs_hook=OrderedDict)
18   
19   oldfiles = sums["files"]
20   newfiles = OrderedDict([entry for entry in oldfiles.items() if os.path.exists(entry[0])])
21   sums["files"] = newfiles
22   
23   if len(oldfiles) > len(newfiles):
24     with open(".cargo-checksum.json", "w") as fp:
25       json.dump(sums, fp, separators=(',', ':'))
26
27 if __name__ == "__main__":
28   main(sys.argv[1] if len(sys.argv) > 1 else ".")
This page took 0.056477 seconds and 3 git commands to generate.