File size: 833 Bytes
28bf99c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
"""
.. codeauthor:: Tsuyoshi Hombashi <[email protected]>
"""
from typing import Dict
from typepy import Typecode
from ._align import Align
class AlignGetter:
@property
def typecode_align_table(self):
raise NotImplementedError()
@typecode_align_table.setter
def typecode_align_table(self, x: Dict[Typecode, Align]) -> None:
self.__typecode_align_table = x
def get_align_from_typecode(self, typecode: Typecode) -> Align:
return self.__typecode_align_table.get(typecode, self.default_align)
def __init__(self) -> None:
self.typecode_align_table = {
Typecode.STRING: Align.LEFT,
Typecode.INTEGER: Align.RIGHT,
Typecode.REAL_NUMBER: Align.RIGHT,
}
self.default_align = Align.LEFT
align_getter = AlignGetter()
|