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

Method get_row

rich/box.py:115–162  ·  view source on GitHub ↗

Get the top of a simple box. Args: width (List[int]): Widths of columns. Returns: str: A string of box characters.

(
        self,
        widths: Iterable[int],
        level: Literal["head", "row", "foot", "mid"] = "row",
        edge: bool = True,
    )

Source from the content-addressed store, hash-verified

113 return "".join(parts)
114
115 def get_row(
116 self,
117 widths: Iterable[int],
118 level: Literal["head", "row", "foot", "mid"] = "row",
119 edge: bool = True,
120 ) -> str:
121 """Get the top of a simple box.
122
123 Args:
124 width (List[int]): Widths of columns.
125
126 Returns:
127 str: A string of box characters.
128 """
129 if level == "head":
130 left = self.head_row_left
131 horizontal = self.head_row_horizontal
132 cross = self.head_row_cross
133 right = self.head_row_right
134 elif level == "row":
135 left = self.row_left
136 horizontal = self.row_horizontal
137 cross = self.row_cross
138 right = self.row_right
139 elif level == "mid":
140 left = self.mid_left
141 horizontal = " "
142 cross = self.mid_vertical
143 right = self.mid_right
144 elif level == "foot":
145 left = self.foot_row_left
146 horizontal = self.foot_row_horizontal
147 cross = self.foot_row_cross
148 right = self.foot_row_right
149 else:
150 raise ValueError("level must be 'head', 'row' or 'foot'")
151
152 parts: List[str] = []
153 append = parts.append
154 if edge:
155 append(left)
156 for last, width in loop_last(widths):
157 append(horizontal * width)
158 if not last:
159 append(cross)
160 if edge:
161 append(right)
162 return "".join(parts)
163
164 def get_bottom(self, widths: Iterable[int]) -> str:
165 """Get the bottom of a simple box.

Callers 2

test_get_rowFunction · 0.80
_renderMethod · 0.80

Calls 2

loop_lastFunction · 0.85
joinMethod · 0.80

Tested by 1

test_get_rowFunction · 0.64