def outdated(self):
""" Fetch outdated packages from ``brew outdated`` output.
Raw CLI output samples:
.. code-block:: shell-session
$ brew outdated --json=v1
[
{
"name": "cassandra",
"installed_versions": [
"3.5"
],
"current_version": "3.7"
},
{
"name": "vim",
"installed_versions": [
"7.4.1967"
],
"current_version": "7.4.1993"
},
{
"name": "youtube-dl",
"installed_versions": [
"2016.07.06"
],
"current_version": "2016.07.09.1"
}
]
"""
outdated = {}
# List available updates.
output = self.run(
[self.cli_path] + self.cli_args + ['outdated', '--json=v1'])
if output:
for pkg_info in json.loads(output):
# Parse versions to avoid lexicographic sorting gotchas.
version = None
versions = set(pkg_info['installed_versions'])
if versions:
_, version = max([(parse_version(v), v) for v in versions])
package_id = pkg_info['name']
outdated[package_id] = {
'id': package_id,
'name': package_id,
'installed_version': version,
'latest_version': pkg_info['current_version']}
return outdated
评论列表
文章目录