Files
revng-revng/python/revng/support/__init__.py
T
Giacomo Vercesi e4adbe8134 revng.support: add get_root
Add the get_root function which will return the absolute path of the
root, relatively to the file location in support
2022-10-24 09:58:55 +02:00

25 lines
627 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
from collections.abc 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,)
# We assume this file is in <root>/lib/python$VERSION/site-packages/revng/support
def get_root() -> Path:
return (Path(__file__) / "../../../../../../").resolve()