text stringlengths 0 828 |
|---|
:param types_supported: |
:return: |
"""""" |
# base message |
msg = str(obj) + ' cannot be parsed as a ' + get_pretty_type_str(obj_type) + ' because no parser supporting ' \ |
'that type is registered for ' + obj.get_pretty_file_ext() + '.\n' |
# add details |
if types_supported is not None and len(types_supported) > 0: |
msg += ' If you wish to parse this object from this extension, you may wish to parse it as one of the ' \ |
'following supported types : ' + str(types_supported) + '. \n' \ |
+ 'Otherwise, please register a new parser for type ' + get_pretty_type_str(obj_type) \ |
+ ' and extension ' + obj.get_pretty_file_ext() + '\n Reminder: use print_capabilities_by_ext()' \ |
+ ' and print_capabilities_by_type() to diagnose what are the parsers available' |
else: |
raise ValueError('extensions_supported should be provided to create a NoParserFoundForObjectExt. If no ' |
'extension is supported, use NoParserFoundForObjectType.create instead') |
e = NoParserFoundForObjectType(msg) |
# save the extensions supported |
e.types_supported = types_supported |
return e" |
487,"def create(obj: PersistedObject, obj_type: Type[T], errors: Dict[Type, Exception]): |
"""""" |
Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests |
ERROR: type should be string, got " https://github.com/nose-devs/nose/issues/725" |
:param obj: |
:param errors: a dictionary of the errors raised for each alternate type tried |
:return: |
"""""" |
e = NoParserFoundForUnionType('{obj} cannot be parsed as a {typ} because no parser could be found for any of ' |
'the alternate types. Caught exceptions: {errs}' |
''.format(obj=obj, typ=get_pretty_type_str(obj_type), errs=errors)) |
# save the errors |
e.errors = errors |
return e" |
488,"def register_parsers(self, parsers: List[Parser]): |
"""""" |
Utility method to register any list of parsers. |
:return: |
"""""" |
check_var(parsers, var_types=list, var_name='parsers') |
for parser in parsers: |
self.register_parser(parser)" |
489,"def print_capabilities_by_ext(self, strict_type_matching: bool = False): |
"""""" |
Used to print the list of all file extensions that can be parsed by this parser registry. |
:return: |
"""""" |
print('\nCapabilities by file extension: ') |
l = self.get_capabilities_by_ext(strict_type_matching=strict_type_matching) |
pprint({ext: get_pretty_type_keys_dict(parsers) for ext, parsers in l.items()}) |
print('\n')" |
490,"def print_capabilities_by_type(self, strict_type_matching: bool = False): |
"""""" |
Used to print the list of all file extensions that can be parsed by this parser registry. |
:return: |
"""""" |
print('\nCapabilities by object type: ') |
l = self.get_capabilities_by_type(strict_type_matching=strict_type_matching) |
pprint({get_pretty_type_str(typ): parsers for typ, parsers in l.items()}) |
print('\n')" |
491,"def get_capabilities_by_type(self, strict_type_matching: bool = False) -> Dict[Type, Dict[str, Dict[str, Parser]]]: |
"""""" |
For all types that are supported, |
lists all extensions that can be parsed into such a type. |
For each extension, provides the list of parsers supported. The order is ""most pertinent first"" |
This method is for monitoring and debug, so we prefer to not rely on the cache, but rather on the query engine. |
That will ensure consistency of the results. |
:param strict_type_matching: |
:return: |
"""""" |
check_var(strict_type_matching, var_types=bool, var_name='strict_matching') |
res = dict() |
# List all types that can be parsed |
for typ in self.get_all_supported_types(): |
res[typ] = self.get_capabilities_for_type(typ, strict_type_matching) |
return res" |
492,"def get_capabilities_by_ext(self, strict_type_matching: bool = False) -> Dict[str, Dict[Type, Dict[str, Parser]]]: |
"""""" |
For all extensions that are supported, |
lists all types that can be parsed from this extension. |
For each type, provide the list of parsers supported. The order is ""most pertinent first"" |
This method is for monitoring and debug, so we prefer to not rely on the cache, but rather on the query engine. |
That will ensure consistency of the results. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.