text
stringlengths 0
828
|
|---|
Utility method
|
:param dict_of_list:
|
:param key:
|
:param parser:
|
:return:
|
""""""
|
if key in dict_of_list.keys():
|
dict_of_list[key].append(parser)
|
else:
|
dict_of_list[key] = [parser]"
|
482,"def insert_element_to_dict_of_dicts_of_list(dict_of_dict_of_list, first_key, second_key, parser):
|
""""""
|
Utility method
|
:param dict_of_dict_of_list:
|
:param first_key:
|
:param second_key:
|
:param parser:
|
:return:
|
""""""
|
list_to_insert = parser if isinstance(parser, list) else [parser]
|
if first_key not in dict_of_dict_of_list.keys():
|
dict_of_dict_of_list[first_key] = {second_key: list_to_insert}
|
else:
|
if second_key not in dict_of_dict_of_list[first_key].keys():
|
dict_of_dict_of_list[first_key][second_key] = list_to_insert
|
else:
|
dict_of_dict_of_list[first_key][second_key] += list_to_insert"
|
483,"def insert_element_to_dict_of_dicts(dict_of_dicts: Dict[str, Dict[str, str]], first_key: str, second_key: str, contents):
|
""""""
|
Utility method
|
:param dict_of_dicts:
|
:param first_key:
|
:param second_key:
|
:param contents:
|
:return:
|
""""""
|
if first_key not in dict_of_dicts.keys():
|
dict_of_dicts[first_key] = {second_key: contents}
|
else:
|
if second_key not in dict_of_dicts[first_key].keys():
|
dict_of_dicts[first_key][second_key] = contents
|
else:
|
warn('Overriding contents for ' + first_key + '/' + second_key)
|
dict_of_dicts[first_key][second_key] = contents"
|
484,"def build_parser_for_fileobject_and_desiredtype(self, obj_on_filesystem: PersistedObject, object_type: Type[T],
|
logger: Logger = None) -> Parser:
|
""""""
|
Returns the most appropriate parser to use to parse object obj_on_filesystem as an object of type object_type
|
:param obj_on_filesystem: the filesystem object to parse
|
:param object_type: the type of object that the parser is expected to produce
|
:param logger:
|
:return:
|
""""""
|
pass"
|
485,"def create(obj: PersistedObject, obj_type: Type[T], extensions_supported: Iterable[str]):
|
""""""
|
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 obj_type:
|
:param extensions_supported:
|
:return:
|
""""""
|
# base message
|
msg = ""{obj} cannot be parsed as a {typ} because no parser supporting that extension ({ext}) is able to "" \
|
""create this type of object."" \
|
"""".format(obj=obj, typ=get_pretty_type_str(obj_type), ext=obj.get_pretty_file_ext())
|
# add details
|
if extensions_supported is not None and len(extensions_supported) > 0:
|
msg += "" If you wish to parse this fileobject to that precise type, you may wish to either "" \
|
""(1) replace the file with any of the following extensions currently supported : {exts} "" \
|
""(see get_capabilities_for_type({typ}, strict_type_matching=False) for details)."" \
|
"" Or (2) register a new parser."" \
|
"""".format(exts=extensions_supported, typ=get_pretty_type_str(obj_type))
|
else:
|
raise ValueError('extensions_supported should be provided to create a NoParserFoundForObjectExt. If no '
|
'extension is supported, use NoParserFoundForObjectType.create instead')
|
e = NoParserFoundForObjectExt(msg)
|
# save the extensions supported
|
e.extensions_supported = extensions_supported
|
return e"
|
486,"def create(obj: PersistedObject, obj_type: Type[T], types_supported: Iterable[str]):
|
""""""
|
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 obj_type:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.