Beispiel #1
0
def check_fill_value(fill_value):
    if isinstance(fill_value, int):
        check_uint8(fill_value)
    elif isinstance(fill_value, tuple) and len(fill_value) == 3:
        for value in fill_value:
            check_uint8(value)
    else:
        raise TypeError("fill_value should be a single integer or a 3-tuple.")
Beispiel #2
0
 def new_method(self, *args, **kwargs):
     [bits], _ = parse_user_args(method, *args, **kwargs)
     if bits is not None:
         type_check(bits, (list, tuple, int), "bits")
     if isinstance(bits, int):
         check_value(bits, [1, 8])
     if isinstance(bits, (list, tuple)):
         if len(bits) != 2:
             raise TypeError("Size of bits should be a single integer or a list/tuple (min, max) of length 2.")
         for item in bits:
             check_uint8(item, "bits")
         # also checks if min <= max
         check_range(bits, [1, 8])
     return method(self, *args, **kwargs)