MCPcopy
hub / github.com/Textualize/rich / unpack

Method unpack

rich/padding.py:61–74  ·  view source on GitHub ↗

Unpack padding specified in CSS style.

(pad: "PaddingDimensions")

Source from the content-addressed store, hash-verified

59
60 @staticmethod
61 def unpack(pad: "PaddingDimensions") -> Tuple[int, int, int, int]:
62 """Unpack padding specified in CSS style."""
63 if isinstance(pad, int):
64 return (pad, pad, pad, pad)
65 if len(pad) == 1:
66 _pad = pad[0]
67 return (_pad, _pad, _pad, _pad)
68 if len(pad) == 2:
69 pad_top, pad_right = pad
70 return (pad_top, pad_right, pad_top, pad_right)
71 if len(pad) == 4:
72 top, right, bottom, left = pad
73 return (top, right, bottom, left)
74 raise ValueError(f"1, 2 or 4 integers required for padding; {len(pad)} given")
75
76 def __repr__(self) -> str:
77 return f"Padding({self.renderable!r}, ({self.top},{self.right},{self.bottom},{self.left}))"

Callers 9

__init__Method · 0.95
test_unpackFunction · 0.80
__rich_console__Method · 0.80
__rich_measure__Method · 0.80
__rich_console__Method · 0.80
__set__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
paddingMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_unpackFunction · 0.64