]> git.pld-linux.org Git - packages/cargo.git/blame - cargo-checksums-prune.py
add missing buildroot
[packages/cargo.git] / cargo-checksums-prune.py
CommitLineData
61d3b52c
JR
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
9from collections import OrderedDict
10import json
11import os
12import sys
13
14def 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
27if __name__ == "__main__":
28 main(sys.argv[1] if len(sys.argv) > 1 else ".")
This page took 0.512513 seconds and 4 git commands to generate.