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

Method __rich_measure__

rich/table.py:320–351  ·  view source on GitHub ↗
(
        self, console: "Console", options: "ConsoleOptions"
    )

Source from the content-addressed store, hash-verified

318 return style
319
320 def __rich_measure__(
321 self, console: "Console", options: "ConsoleOptions"
322 ) -> Measurement:
323 max_width = options.max_width
324 if self.width is not None:
325 max_width = self.width
326 if max_width < 0:
327 return Measurement(0, 0)
328
329 extra_width = self._extra_width
330 max_width = sum(
331 self._calculate_column_widths(
332 console, options.update_width(max_width - extra_width)
333 )
334 )
335 _measure_column = self._measure_column
336
337 measurements = [
338 _measure_column(console, options.update_width(max_width), column)
339 for column in self.columns
340 ]
341 minimum_width = (
342 sum(measurement.minimum for measurement in measurements) + extra_width
343 )
344 maximum_width = (
345 sum(measurement.maximum for measurement in measurements) + extra_width
346 if (self.width is None)
347 else self.width
348 )
349 measurement = Measurement(minimum_width, maximum_width)
350 measurement = measurement.clamp(self.min_width)
351 return measurement
352
353 @property
354 def padding(self) -> Tuple[int, int, int, int]:

Callers 1

test_min_widthFunction · 0.95

Calls 4

clampMethod · 0.95
MeasurementClass · 0.85
update_widthMethod · 0.80

Tested by 1

test_min_widthFunction · 0.76