rainbowadn/rainbowadn/core/hash_point_format.py
2022-06-19 22:53:02 +03:00

27 lines
699 B
Python

from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.mentionable import Mentionable
from rainbowadn.core.recursivementionable import RecursiveMentionable
__all__ = ('hash_point_format', 'tabulate',)
async def hash_point_format(hash_point: HashPoint, tab: int) -> str:
assert isinstance(hash_point, HashPoint)
assert isinstance(tab, int)
value: Mentionable = await hash_point.resolve()
if isinstance(value, RecursiveMentionable):
return await value.str(tab)
else:
return str(value)
newline = False
def tabulate(tab: int) -> str:
assert isinstance(tab, int)
if newline:
return '\n' + ' ' * tab
else:
return ' '