Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions docs/walkthroughs/make_fossa_deps_conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ def mk_fossa_deps(graph):

vendored_deps = []
custom_deps = []
for node in graph.get('nodes', []):
for nodeName in graph.get('nodes', []):
node = graph['nodes'][nodeName]
Comment on lines +128 to +129
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break on older versions of conan, right? Do we want to support both versions?

I think we could do that by looking at the type of graph.get('nodes', []). Something like this:

  nodes_data = graph.get('nodes', [])
  if isinstance(nodes_data, list):
      nodes_iter = nodes_data  # Conan 1.x
  else:
      nodes_iter = nodes_data.values()  # Conan 2.x

It would be worth testing against both versions, IMO, to make sure that there aren't other breaking changes

label = node.get("label")
if label.lower() in ["conanfile.txt", "conanfile.py"]:
if label.lower() in ["conanfile.txt", "conanfile.py"] or node.get("recipe") == "Consumer":
logging.info(f"excluding {label} from fossa-deps, as this is a manifest file, not a dependency")
continue

Expand All @@ -140,7 +141,10 @@ def mk_fossa_deps(graph):
continue

pkg_id = node.get("package_id", "none")
name, raw_version = name_version_of(label)
name = node.get("name")
raw_version = node.get("version")
if not name or not raw_version:
name, raw_version = name_version_of(label)
version_params = urllib.parse.urlencode({'package_id': pkg_id}, doseq=True)
version = f"{raw_version},{version_params}"

Expand Down Expand Up @@ -181,4 +185,6 @@ def get_graph(user_args = []):

if __name__ == "__main__":
graph = get_graph(sys.argv[1:])
mk_fossa_deps(graph)
if 'graph' in graph:
graph = graph['graph']
mk_fossa_deps(graph)
Loading