[utils] Fix match_str for boolean meta fields
This commit is contained in:
		
							parent
							
								
									99036a1298
								
							
						
					
					
						commit
						1cc47c6674
					
				
					 2 changed files with 14 additions and 2 deletions
				
			
		| 
						 | 
					@ -1072,6 +1072,18 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4')
 | 
				
			||||||
        self.assertFalse(match_str(
 | 
					        self.assertFalse(match_str(
 | 
				
			||||||
            'like_count > 100 & dislike_count <? 50 & description',
 | 
					            'like_count > 100 & dislike_count <? 50 & description',
 | 
				
			||||||
            {'like_count': 190, 'dislike_count': 10}))
 | 
					            {'like_count': 190, 'dislike_count': 10}))
 | 
				
			||||||
 | 
					        self.assertTrue(match_str('is_live', {'is_live': True}))
 | 
				
			||||||
 | 
					        self.assertFalse(match_str('is_live', {'is_live': False}))
 | 
				
			||||||
 | 
					        self.assertFalse(match_str('is_live', {'is_live': None}))
 | 
				
			||||||
 | 
					        self.assertFalse(match_str('is_live', {}))
 | 
				
			||||||
 | 
					        self.assertFalse(match_str('!is_live', {'is_live': True}))
 | 
				
			||||||
 | 
					        self.assertTrue(match_str('!is_live', {'is_live': False}))
 | 
				
			||||||
 | 
					        self.assertTrue(match_str('!is_live', {'is_live': None}))
 | 
				
			||||||
 | 
					        self.assertTrue(match_str('!is_live', {}))
 | 
				
			||||||
 | 
					        self.assertTrue(match_str('title', {'title': 'abc'}))
 | 
				
			||||||
 | 
					        self.assertTrue(match_str('title', {'title': ''}))
 | 
				
			||||||
 | 
					        self.assertFalse(match_str('!title', {'title': 'abc'}))
 | 
				
			||||||
 | 
					        self.assertFalse(match_str('!title', {'title': ''}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_parse_dfxp_time_expr(self):
 | 
					    def test_parse_dfxp_time_expr(self):
 | 
				
			||||||
        self.assertEqual(parse_dfxp_time_expr(None), None)
 | 
					        self.assertEqual(parse_dfxp_time_expr(None), None)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2574,8 +2574,8 @@ def _match_one(filter_part, dct):
 | 
				
			||||||
        return op(actual_value, comparison_value)
 | 
					        return op(actual_value, comparison_value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    UNARY_OPERATORS = {
 | 
					    UNARY_OPERATORS = {
 | 
				
			||||||
        '': lambda v: v is not None,
 | 
					        '': lambda v: (v is True) if isinstance(v, bool) else (v is not None),
 | 
				
			||||||
        '!': lambda v: v is None,
 | 
					        '!': lambda v: (v is False) if isinstance(v, bool) else (v is None),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    operator_rex = re.compile(r'''(?x)\s*
 | 
					    operator_rex = re.compile(r'''(?x)\s*
 | 
				
			||||||
        (?P<op>%s)\s*(?P<key>[a-z_]+)
 | 
					        (?P<op>%s)\s*(?P<key>[a-z_]+)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue