Returns true if matches . Each item in is a type or tuple of types. Any of these types will match an item in . `None` will match anything in . `type(None)` will match an arg whose value is `None`.
(args, *types)
| 22173 | |
| 22174 | |
| 22175 | def args_match(args, *types): |
| 22176 | ''' |
| 22177 | Returns true if <args> matches <types>. |
| 22178 | |
| 22179 | Each item in <types> is a type or tuple of types. Any of these types will |
| 22180 | match an item in <args>. `None` will match anything in <args>. `type(None)` |
| 22181 | will match an arg whose value is `None`. |
| 22182 | ''' |
| 22183 | j = 0 |
| 22184 | for i in range(len(types)): |
| 22185 | type_ = types[i] |
| 22186 | if j >= len(args): |
| 22187 | if isinstance(type_, tuple) and None in type_: |
| 22188 | # arg is missing but has default value. |
| 22189 | continue |
| 22190 | else: |
| 22191 | return False |
| 22192 | if type_ is not None and not isinstance(args[j], type_): |
| 22193 | return False |
| 22194 | j += 1 |
| 22195 | if j != len(args): |
| 22196 | return False |
| 22197 | return True |
| 22198 | |
| 22199 | |
| 22200 | def calc_image_matrix(width, height, tr, rotate, keep): |