Skip to content

Commit

Permalink
conan: treat the conan inspect output as a json format
Browse files Browse the repository at this point in the history
  • Loading branch information
YasLbk authored and Yassine Lambarki committed Aug 12, 2024
1 parent 27ac22b commit 0d61110
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/conan_check_updates/conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from itertools import chain
from pathlib import Path
from typing import AsyncIterator, List, Optional, Tuple
import json

from .version import (
Version,
Expand Down Expand Up @@ -213,20 +214,12 @@ def get_command():
args = chain.from_iterable(("-a", attr) for attr in _REQUIRES_ATTRIBUTES)
return ("conan", "inspect", str(conanfile), *args)
if conan_version().major == 2: # noqa: PLR2004
return ("conan", "inspect", str(conanfile))
return ("conan", "inspect", str(conanfile), "--format=json")
raise RuntimeError(f"Conan version {conan_version()!s} not supported")

stdout, _ = _run_capture(*get_command(), timeout=TIMEOUT)

def gen_dict():
for line in stdout.decode().splitlines():
key, _, value = (part.strip() for part in line.partition(":"))
if key and value:
if value.startswith(("(", "[")) and value.endswith((")", "]")):
value = literal_eval(value)
yield key, value

attributes = dict(gen_dict())
attributes = dict(json.loads(stdout.decode()))

def gen_requires():
for key, value in attributes.items():
Expand Down

0 comments on commit 0d61110

Please sign in to comment.