text
stringlengths 0
828
|
---|
Explicitly declare that we are not able to parse collections
|
:param desired_type:
|
:param desired_ext:
|
:param strict:
|
:return:
|
""""""
|
if not _is_valid_for_dict_to_object_conversion(strict, None, None if desired_type is JOKER else desired_type):
|
return False, None
|
else:
|
return super(MultifileObjectParser, self).is_able_to_parse_detailed(desired_type, desired_ext, strict)"
|
362,"def _get_parsing_plan_for_multifile_children(self, obj_on_fs: PersistedObject, desired_type: Type[Any],
|
logger: Logger) -> Dict[str, Any]:
|
""""""
|
Simply inspects the required type to find the names and types of its constructor arguments.
|
Then relies on the inner ParserFinder to parse each of them.
|
:param obj_on_fs:
|
:param desired_type:
|
:param logger:
|
:return:
|
""""""
|
if is_collection(desired_type, strict=True):
|
# if the destination type is 'strictly a collection' (not a subclass of a collection) we know that we can't
|
# handle it here, the constructor is not pep484-typed
|
raise TypeError('Desired object type \'' + get_pretty_type_str(desired_type) + '\' is a collection, '
|
'so it cannot be parsed with this default object parser')
|
else:
|
# First get the file children
|
children_on_fs = obj_on_fs.get_multifile_children()
|
# Try the type itself
|
# try:
|
return self.__get_parsing_plan_for_multifile_children(obj_on_fs, desired_type, children_on_fs,
|
logger=logger)"
|
363,"def __get_parsing_plan_for_multifile_children(self, obj_on_fs: PersistedObject, desired_type: Type[Any],
|
children_on_fs: Dict[str, PersistedObject], logger: Logger) \
|
-> Dict[str, Any]:
|
""""""
|
Simply inspects the required type to find the names and types of its constructor arguments.
|
Then relies on the inner ParserFinder to parse each of them.
|
:param obj_on_fs:
|
:param desired_type:
|
:param children_on_fs:
|
:param logger:
|
:return:
|
""""""
|
# -- (a) collect pep-484 information in the class constructor to be able to understand what is required
|
constructor_args_types_and_opt = get_constructor_attributes_types(desired_type)
|
# -- (b) plan to parse each attribute required by the constructor
|
children_plan = dict() # results will be put in this object
|
# --use sorting in order to lead to reproducible results in case of multiple errors
|
for attribute_name, att_desc in sorted(constructor_args_types_and_opt.items()):
|
attribute_is_mandatory = att_desc[1]
|
attribute_type = att_desc[0]
|
# get the child
|
if attribute_name in children_on_fs.keys():
|
child_on_fs = children_on_fs[attribute_name]
|
# find a parser
|
t, parser_found = self.parser_finder.build_parser_for_fileobject_and_desiredtype(child_on_fs,
|
attribute_type,
|
logger=logger)
|
# create a parsing plan
|
children_plan[attribute_name] = parser_found.create_parsing_plan(t, child_on_fs,
|
logger=logger, _main_call=False)
|
else:
|
if attribute_is_mandatory:
|
raise MissingMandatoryAttributeFiles.create(obj_on_fs, desired_type, attribute_name)
|
else:
|
# we don't care : optional attribute
|
# dont use warning since it does not show up nicely
|
msg = 'NOT FOUND - This optional constructor attribute for type ' \
|
+ get_pretty_type_str(desired_type) + ' was not found on file system, but this may be normal'\
|
' - this message is displayed \'just in case\'.'
|
if logger.isEnabledFor(DEBUG):
|
logger.warning('(B) ' + obj_on_fs.get_pretty_child_location(attribute_name,
|
blank_parent_part=True) + ': '
|
+ msg)
|
else:
|
logger.warning('WARNING parsing [{loc}] as a [{typ}]: optional constructor attribute [{att}] '
|
'not found on file system. This may be normal - this message is displayed \'just'
|
' in case\'.'.format(
|
loc=obj_on_fs.get_pretty_location(blank_parent_part=False, append_file_ext=False),
|
typ=get_pretty_type_str(desired_type),
|
att=attribute_name))
|
return children_plan"
|
364,"def parsyfiles_global_config(multiple_errors_tb_limit: int = None, full_paths_in_logs: bool = None,
|
dict_to_object_subclass_limit: int = None):
|
""""""
|
This is the method you should use to configure the parsyfiles library
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.