text
stringlengths
0
828
:param strict:
:return:
""""""
matching = self.find_all_matching_parsers(desired_type=type_to_match, strict=strict)[0]
return {ext for exts in [p.supported_exts for p in (matching[0] + matching[1] + matching[2])]
for ext in exts}"
498,"def find_all_matching_parsers(self, strict: bool, desired_type: Type[Any] = JOKER, required_ext: str = JOKER) \
-> Tuple[Tuple[List[Parser], List[Parser], List[Parser]],
List[Parser], List[Parser], List[Parser]]:
""""""
Implementation of the parent method by lookin into the registry to find the most appropriate parsers to use in
order
:param strict:
:param desired_type: the desired type, or 'JOKER' for a wildcard
:param required_ext:
:return: match=(matching_parsers_generic, matching_parsers_approx, matching_parsers_exact),
no_type_match_but_ext_match, no_ext_match_but_type_match, no_match
""""""
# if desired_type is JOKER and required_ext is JOKER:
# # Easy : return everything (GENERIC first, SPECIFIC then) in order (make a copy first :) )
# matching_parsers_generic = self._generic_parsers.copy()
# matching_parsers_approx = []
# matching_parsers_exact = self._specific_parsers.copy()
# no_type_match_but_ext_match = []
# no_ext_match_but_type_match = []
# no_match = []
# else:
#
# Although the above could be thought as an easy way to accelerate the process, it does not any more since the
# JOKER special cases are handled in parser.is_able_to_parse and converter.is_able_to_convert functions.
#
# It was also dangerous since it prevented us to get consistency across views - hence parser/converter
# implementors could get the feeling that their parser was correctly registered where it wasn't
check_var(strict, var_types=bool, var_name='strict')
# first transform any 'Any' type requirement into the official class for that
desired_type = get_validated_type(desired_type, 'desired_type', enforce_not_joker=False)
matching_parsers_generic = []
matching_parsers_approx = []
matching_parsers_exact = []
no_type_match_but_ext_match = []
no_ext_match_but_type_match = []
no_match = []
# handle generic parsers first - except if desired type is Any
for p in self._generic_parsers:
match = p.is_able_to_parse(desired_type=desired_type, desired_ext=required_ext, strict=strict)
if match:
# match
if is_any_type(desired_type):
# special case : what is required is Any, so put in exact match
matching_parsers_exact.append(p)
else:
matching_parsers_generic.append(p)
else:
# check if by releasing the constraint on ext it makes a match
if p.is_able_to_parse(desired_type=desired_type, desired_ext=JOKER, strict=strict):
no_ext_match_but_type_match.append(p)
else:
# there will be no way to use this: it is a generic parser that is not able to parse this type...
# no_type_match_but_ext_match.append(p)
pass
# then the specific
for p in self._specific_parsers:
match, exact_match = p.is_able_to_parse_detailed(desired_type=desired_type,
desired_ext=required_ext,
strict=strict)
if match:
if is_any_type(desired_type):
# special case: dont register as a type match
no_type_match_but_ext_match.append(p)
else:
if exact_match is None or exact_match:
matching_parsers_exact.append(p)
else:
matching_parsers_approx.append(p)
else:
# try to set the type to a supported type to see if that makes a match
if p.is_able_to_parse(desired_type=JOKER, desired_ext=required_ext, strict=strict):
no_type_match_but_ext_match.append(p)
# try to set the ext to a supported ext to see if that makes a match
elif p.is_able_to_parse(desired_type=desired_type, desired_ext=JOKER, strict=strict):
no_ext_match_but_type_match.append(p)
# no match at all
else:
no_match.append(p)
return (matching_parsers_generic, matching_parsers_approx, matching_parsers_exact), \
no_type_match_but_ext_match, no_ext_match_but_type_match, no_match"
499,"def _create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
log_only_last: bool = False) -> ParsingPlan[T]:
""""""