def _BinarySizeOrAny(default_unit): """Parses the value 'any' or a binary size converted to the default unit.""" # pylint: disable=protected-access bytes_per_unit = scaled_integer.GetBinaryUnitSize(default_unit) def _Parse(value): value = value.lower() if value == 'any': return value size = arg_parsers.BinarySize(default_unit=default_unit)(value) converted_size = size // bytes_per_unit return str(converted_size) return _Parse
def _BinarySize(default_unit, lower_bound=None, upper_bound=None): """Parses the value as a binary size converted to the default unit.""" # pylint: disable=protected-access bytes_per_unit = scaled_integer.GetBinaryUnitSize(default_unit) def _Parse(value): value = value.lower() size = arg_parsers.BinarySize( lower_bound=lower_bound, upper_bound=upper_bound, default_unit=default_unit)(value) converted_size = size // bytes_per_unit return converted_size return _Parse