mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
3e3779498e
Add a python interface (`revng.profile`) for interacting with the rev.ng infrastructure as a whole; either through the CLI (`CLIProject`) or the GraphQL API (`DaemonProject`).
38 lines
883 B
Python
38 lines
883 B
Python
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
|
|
from typing import Mapping
|
|
|
|
|
|
class AllMixin:
|
|
"""
|
|
Base mixin for all the objects in the `Binary` that don't support getting the artifacts.
|
|
"""
|
|
|
|
_project = None
|
|
_keys = None
|
|
|
|
|
|
class _ArtifactMixin(AllMixin):
|
|
"""
|
|
Mixin used to implement the get_artifact function
|
|
"""
|
|
|
|
def get_artifact(self, artifact_name: str):
|
|
"""
|
|
Fetch the artifacts from the `Binary`.
|
|
"""
|
|
result = self._project.get_artifact(artifact_name, [self]) # type: ignore[attr-defined]
|
|
if isinstance(result, Mapping):
|
|
keys = list(result.keys())
|
|
assert len(keys) == 1
|
|
return result[keys[0]]
|
|
else:
|
|
return result
|
|
|
|
|
|
BinaryMixin = _ArtifactMixin
|
|
FunctionMixin = _ArtifactMixin
|
|
TypeDefinitionMixin = _ArtifactMixin
|