intficpy/parser.py
def _checkComponentObject(self, which_obj, obj):
        """
        Check if the given object has a subcomponent that is a better candidate for
        object of the current verb.

        Takes arguments
        - obj_words, the words from the player comman that specify the object
        - which_obj, a string "dobj" or "iobj" specifying whether this object is direc
          or indirect
        - obj, the Thing instance to examine

        Raises TypeError if passed an invalid parameter for which_obj
        """

        COMPONENT_CLASSES = {
            "Container": {"class": Container, "component_holder": "child_Containers"},
            "Surface": {"class": Surface, "component_holder": "child_Surfaces"},
            "UnderSpace": {
                "class": UnderSpace,
                "component_holder": "child_UnderSpaces",
            },
        }

        if not which_obj in ("dobj", "iobj"):
            raise TypeError(f'Invalid object specifier "{which_obj}".')

        scope = getattr(self.command.verb, f"{which_obj[:1]}scope")
        far_obj = getattr(self.command.verb, f"far_{which_obj}")
        obj_direction = getattr(self.command.verb, f"{which_obj}_direction")
        obj_type = getattr(self.command.verb, f"{which_obj[:1]}type")
        grammar_obj = getattr(self.command, which_obj)

        if scope == "text" or scope == "direction" or not obj:
            return obj

        if (
            obj_type
            and not obj.__class__.__name__ == obj_type
            and obj_type in COMPONENT_CLASSES
        ):
            components = getattr(obj, COMPONENT_CLASSES[obj_type]["component_holder"])
            matched_component = self.checkAdjectives(
                grammar_obj.tokens,
                grammar_obj.noun_token,
                components,
                scope,
                far_obj,
                obj_direction,
            )
            if matched_component:
                return matched_component

        return obj

        Check if the given object has a subcomponent that is a better candidate for
        object of the current verb.

        Takes arguments
        - obj_words, the words from the player comman that specify the object
        - which_obj, a string "dobj" or "iobj" specifying whether this object is direc
          or indirect
        - obj, the Thing instance to examine

        Raises TypeError if passed an invalid parameter for which_obj
        
Check if the given object has a subcomponent that is a better candidate for
object of the current verb.

Takes arguments
obj_words, the words from the player comman that specify the object
which_obj, a string "dobj" or "iobj" specifying whether this object is direc
or indirect
obj, the Thing instance to examine

Raises TypeError if passed an invalid parameter for which_obj
Check if the given object has a subcomponent that is a better candidate for object of the current verb . Takes arguments obj_words the words from the player comman that specify the object which_obj a string " dobj " or " iobj " specifying whether this object is direc or indirect obj the Thing instance to examine Raises TypeError if passed an invalid parameter for which_obj
def _checkComponentObject(self, which_obj, obj):
        COMPONENT_CLASSES = {
            "Container": {"class": Container, "component_holder": "child_Containers"},
            "Surface": {"class": Surface, "component_holder": "child_Surfaces"},
            "UnderSpace": {
                "class": UnderSpace,
                "component_holder": "child_UnderSpaces",
            },
        }
        if not which_obj in ("dobj", "iobj"):
            raise TypeError(f'Invalid object specifier "{which_obj}".')
        scope = getattr(self.command.verb, f"{which_obj[:1]}scope")
        far_obj = getattr(self.command.verb, f"far_{which_obj}")
        obj_direction = getattr(self.command.verb, f"{which_obj}_direction")
        obj_type = getattr(self.command.verb, f"{which_obj[:1]}type")
        grammar_obj = getattr(self.command, which_obj)
        if scope == "text" or scope == "direction" or not obj:
            return obj
        if (
            obj_type
            and not obj.__class__.__name__ == obj_type
            and obj_type in COMPONENT_CLASSES
        ):
            components = getattr(obj, COMPONENT_CLASSES[obj_type]["component_holder"])
            matched_component = self.checkAdjectives(
                grammar_obj.tokens,
                grammar_obj.noun_token,
                components,
                scope,
                far_obj,
                obj_direction,
            )
            if matched_component:
                return matched_component
        return obj
def _checkComponentObject ( self , which_obj , obj ) : COMPONENT_CLASSES = { "Container" : { "class" : Container , "component_holder" : "child_Containers" } , "Surface" : { "class" : Surface , "component_holder" : "child_Surfaces" } , "UnderSpace" : { "class" : UnderSpace , "component_holder" : "child_UnderSpaces" , } , } if not which_obj in ( "dobj" , "iobj" ) : raise TypeError ( f'Invalid object specifier "{which_obj}".' ) scope = getattr ( self . command . verb , f"{which_obj[:1]}scope" ) far_obj = getattr ( self . command . verb , f"far_{which_obj}" ) obj_direction = getattr ( self . command . verb , f"{which_obj}_direction" ) obj_type = getattr ( self . command . verb , f"{which_obj[:1]}type" ) grammar_obj = getattr ( self . command , which_obj ) if scope == "text" or scope == "direction" or not obj : return obj if ( obj_type and not obj . __class__ . __name__ == obj_type and obj_type in COMPONENT_CLASSES ) : components = getattr ( obj , COMPONENT_CLASSES [ obj_type ] [ "component_holder" ] ) matched_component = self . checkAdjectives ( grammar_obj . tokens , grammar_obj . noun_token , components , scope , far_obj , obj_direction , ) if matched_component : return matched_component return obj
Check if the given object has a subcomponent that is a better candidate for
object of the current verb.
Check if the given object has a subcomponent that is a better candidate for object of the current verb .
"""
        Check if the given object has a subcomponent that is a better candidate for
        object of the current verb.

        Takes arguments
        - obj_words, the words from the player comman that specify the object
        - which_obj, a string "dobj" or "iobj" specifying whether this object is direc
          or indirect
        - obj, the Thing instance to examine

        Raises TypeError if passed an invalid parameter for which_obj
        """
self
which_obj
obj