You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					18 lines
				
				546 B
			
		
		
			
		
	
	
					18 lines
				
				546 B
			| 
								 
											3 years ago
										 
									 | 
							
								import typing
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class Middleware:
							 | 
						||
| 
								 | 
							
								    def __init__(self, cls: type, **options: typing.Any) -> None:
							 | 
						||
| 
								 | 
							
								        self.cls = cls
							 | 
						||
| 
								 | 
							
								        self.options = options
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def __iter__(self) -> typing.Iterator:
							 | 
						||
| 
								 | 
							
								        as_tuple = (self.cls, self.options)
							 | 
						||
| 
								 | 
							
								        return iter(as_tuple)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def __repr__(self) -> str:
							 | 
						||
| 
								 | 
							
								        class_name = self.__class__.__name__
							 | 
						||
| 
								 | 
							
								        option_strings = [f"{key}={value!r}" for key, value in self.options.items()]
							 | 
						||
| 
								 | 
							
								        args_repr = ", ".join([self.cls.__name__] + option_strings)
							 | 
						||
| 
								 | 
							
								        return f"{class_name}({args_repr})"
							 |