27 lines
699 B
Python
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 ' '
|