@@ -99,13 +99,23 @@ def reset(self) -> None:
9999 """
100100 self .value = None
101101
102- def parse_message (self , message : MessageMixin ,
102+ def parse_message (self ,
103+ message : MessageMixin ,
104+ original_message_content : tuple [str ],
103105 memoization : dict = None ) -> None :
104106 """
105107 Walk the message and parse it for values.
106108 If the identified value exists in memoization,
107109 traverse on until value is returned or the
108110 message is exhausted.
111+
112+ :param message: A Message object to pass to each EntityField,
113+ for parsing entities.
114+ :param original_message_content: The original untouched contents of
115+ the message as received from the client. This is used for a source
116+ of truth, since the content in `message` is mutated with each entity
117+ field parsing it.
118+ :param memoization: Dictionary with previously identified entities
109119 """
110120 self ._prepare_params ()
111121 if self .valid_strings :
@@ -305,7 +315,7 @@ def _identify_value(self, message: MessageMixin,
305315 # sure it complies with Pre- and/or suffix values, if configured
306316 if self .identifier is not None :
307317 identifier_object = self .identifier (start_index = start_index )
308- identifier_entity = identifier_object .try_identify_entity (message )
318+ identifier_entity = identifier_object .try_identify_entity (message )
309319
310320 if identifier_entity is not None :
311321 allowed_scenarios = {
@@ -393,17 +403,22 @@ def _identify_value(self, message: MessageMixin,
393403
394404
395405def parse_entities (message : MessageMixin ,
396- entity_fields : dict ,
397- exclude : tuple = None ) -> dict :
406+ entity_fields : dict [str , EntityFieldValueParser ],
407+ original_message_content : tuple [str ],
408+ exclude : tuple = None ) -> dict [str , str ]:
398409 """
399410 Traverse over all fields which are EntityFieldValueParser subclasses.
400411 Have them identify their values according to their
401412 constraints and conditions, and store them in a
402413 dictionary, returned at the end of parsing.
403- :param exclude:
404- :param entity_fields:
414+ :param original_message_content: The original untouched contents of
415+ the message as received from the client. This is used for a source
416+ of truth, since the content in `message` is mutated with each entity
417+ field parsing it.
418+ :param exclude: Optional tuple of strings to ignore in parsing.
419+ :param entity_fields: Dictionary with `name: EntityField` mapped
405420 :param message: MessageMixin subclass object to be parsed.
406- :return:
421+ :return: Dictionary with the name of the entity against its parsed value.
407422 """
408423 output = {}
409424 if exclude is None :
@@ -426,7 +441,8 @@ def parse_entities(message: MessageMixin,
426441 entity_field_instance .exclude = exclude
427442 entity_field_instance .parse_message (
428443 message ,
429- memoization = parsers_memoization )
444+ memoization = parsers_memoization ,
445+ original_message_content = original_message_content )
430446
431447 # See what the parser found - Entity or None.
432448 # Ignore entities in self.exclude.
@@ -458,6 +474,9 @@ def parse_entities(message: MessageMixin,
458474 parser_joined_suffixes_and_prefixes )
459475
460476 for field_name , entity in reversed (output .items ()):
477+ if entity .is_boolean ():
478+ continue
479+
461480 entity_field = entity_fields .get (field_name )
462481 duplicate_cache .update (entity_field .case_preserved_cache )
463482 value_for_type_conversion = entity_field .default
0 commit comments