MCPcopy
hub / github.com/django/django / match

Method match

django/http/request.py:769–796  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

767 return params
768
769 def match(self, other):
770 if not other:
771 return False
772
773 if not isinstance(other, MediaType):
774 other = MediaType(other)
775
776 main_types = [self.main_type, other.main_type]
777 sub_types = [self.sub_type, other.sub_type]
778
779 # Main types and sub types must be defined.
780 if not all((*main_types, *sub_types)):
781 return False
782
783 # Main types must match or one be "*", same for sub types.
784 for this_type, other_type in (main_types, sub_types):
785 if this_type != other_type and this_type != "*" and other_type != "*":
786 return False
787
788 if bool(self.range_params) == bool(other.range_params):
789 # If both have params or neither have params, they must be
790 # identical.
791 result = self.range_params == other.range_params
792 else:
793 # If self has params and other does not, it's a match.
794 # If other has params and self does not, don't match.
795 result = bool(self.range_params or not other.range_params)
796 return result
797
798 @cached_property
799 def quality(self):

Callers 15

accepted_typeMethod · 0.95
converterMethod · 0.45
intcommaFunction · 0.45
gdal_version_infoFunction · 0.45
__init__Method · 0.45
__init__Method · 0.45
from_ewktMethod · 0.45
__init__Method · 0.45
fromfileFunction · 0.45
deserializeMethod · 0.45
check_relate_argumentMethod · 0.45
__getattr__Method · 0.45

Calls 1

MediaTypeClass · 0.85

Tested by 11

test_kmlMethod · 0.36
test_geojsonMethod · 0.36
test_asgmlMethod · 0.36
test05_geometriesMethod · 0.36
test_matchMethod · 0.36
test_no_matchMethod · 0.36
get_matching_importsMethod · 0.36
test_csrf_tokenMethod · 0.36