Files
revng-revng/python/revng/support/__init__.py
T
Giacomo Vercesi 79c6086d0d revng.api: autodetect files
`revng.api` now autodetects files (libraries, pipeline yamls) for
initialization via the same mechanism used by `revng.cli`. This removes
the need to pass them via environment variables from `revng daemon`
and allows easy interaction with python's C API.
2022-06-29 14:49:29 +02:00

20 lines
454 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
from collections import Iterable as CIterable
from pathlib import Path
from typing import Iterable, TypeVar, Union
T = TypeVar("T")
SingleOrIterable = Union[T, Iterable[T]]
AnyPath = Union[str, Path]
AnyPaths = SingleOrIterable[AnyPath]
def to_iterable(obj: SingleOrIterable[T]) -> Iterable[T]:
if isinstance(obj, CIterable):
return obj
return (obj,)