bytesize._config module

Configuration of the bytesize package.

class bytesize._config.InputConfig(unit=B, method=Round down.)

Bases: object

Configuration for input of Sizes.

Specifies rounding unit and method for Sizes constructed from user input.

method
unit
class bytesize._config.SizeConfig

Bases: object

Configuration for Size class.

INPUT_CONFIG = InputConfig(method=Round down., unit=B)
STRICT = False
STR_CONFIG = StrConfig(binary_units=True, exact_value=False, max_places=2, min_value=False, show_approx_str=True, strip=False)
classmethod set_input_config(config)

Set the configuration for input method for all Size objects.

:param InputConfig config: a configuration object

classmethod set_str_config(config)

Set the configuration for __str__ method for all Size objects.

:param StrConfig config: a configuration object

class bytesize._config.StrConfig(max_places=2, strip=False, min_value=1, binary_units=True, show_approx_str=True, exact_value=False)

Bases: object

Configuration for __str__ method.

If max_places is set to None, all non-zero digits after the decimal point will be shown. Otherwise, max_places digits will be shown.

If strip is True and there is a fractional quantity, trailing zeros are removed up to (and including) the decimal point.

min_value sets the smallest value allowed. If min_value is 10, then single digits on the lhs of the decimal will be avoided if possible. In that case, 9216 KiB is preferred to 9 MiB. However, 1 B has no alternative. If min_value is 1, however, 9 MiB is preferred. If min_value is 0.1, then 0.75 GiB is preferred to 768 MiB, but 0.05 GiB is still displayed as 51.2 MiB.

The default for strip is False, so that precision is always shown to max_places.

binary_units
exact_value
max_places
min_value
show_approx_str
strip

Previous topic

bytesize._util.misc module

Next topic

bytesize._constants module

This Page