From 40ab2310a30d7347cb5e50dc81c3be0a77088e88 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 25 Mar 2021 13:18:35 +0100 Subject: add cargo_check.py --- cargo_check.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 cargo_check.py diff --git a/cargo_check.py b/cargo_check.py new file mode 100755 index 0000000..3350c56 --- /dev/null +++ b/cargo_check.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# Written by Martin Fischer and licensed under MIT. +from multiprocessing.dummy import Pool +import toml +import requests + +sess = requests.session() +sess.headers['user-agent'] = 'cargo_check.py' + +tasks = [] + +with open('Cargo.toml') as f: + data = toml.load(f) + for name, info in data['dependencies'].items(): + version = info if isinstance(info, str) else info.get('version') + tasks.append((name, version)) + +def check_package(info): + name, version = info + res = sess.get('https://crates.io/api/v1/crates/{}'.format(name)) + latest_version = res.json()['versions'][0] + if latest_version['yanked']: + print(name, 'was yanked') + elif not latest_version['num'].startswith(version): + print('{} is outdated ({}), {} is available'.format(name, version, latest_version['num'])) + +pool = Pool() +pool.map(check_package, tasks) -- cgit v1.2.3