def match_unit(data, p, m='<STR_LIT:a>'):
if data is None:<EOL><INDENT>return p is None<EOL><DEDENT>if m != '<STR_LIT:e>' and isinstance(p, six.string_types):<EOL><INDENT>p = re.compile(p)<EOL><DEDENT>if isinstance(data, Sequence) and not isinstance(data, six.string_types):<EOL><INDENT>return any([match_unit(field, p, m=m)<EOL>for field in data])<EOL><DEDENT>elif isinstance(data, MutableMapping):<EOL><INDENT>return any([match_unit(field, p, m=m)<EOL>for field in data.values()])<EOL><DEDENT>if isinstance(p, tuple):<EOL><INDENT>left, right = p<EOL>return (left <= data) and (data <= right)<EOL><DEDENT>if m == '<STR_LIT:e>':<EOL><INDENT>return six.text_type(data) == p<EOL><DEDENT>return p.search(six.text_type(data)) is not None<EOL>
Match data to basic match unit.