(self, text)
return self.unpack_transactions(_tx)
take in a text and return the parsed stock transactions
take in a text and return the parsed stock transactions
take in a text and return the parsed stock transactions
def parse(self, text):
        """take in a text and return the parsed stock transactions"""
        args = text.split()

        if len(args) == 0:
            # we'll allow blank messages to propagate further in case some
            # other handler cares about them.
            return None

        action_keyword = args[0]
        args = args[1:]
        if not self.location:
            if len(args) == 0:
                # todo: this will change when users are tied to locations
                # though need to make sure that PACK and APPROVE still require location code
                # (since they refer to locations different from the sender's loc)
                raise SMSError("must specify a location code")
            self.case, self.location = self.get_supply_point_and_location(args[0])
            args = args[1:]

        action = self.commtrack_settings.action_by_keyword(action_keyword)
        if action:
            # TODO: support single-action by product, as well as by action?
            self.verify_location_registration()
            self.case_id = self.case.case_id
            _tx = self.single_action_transactions(action, args)
        else:
            # initial keyword not recognized; delegate to another handler
            return None

        return self.unpack_transactions(_tx)
def parse ( self , text ) : args = text . split ( ) if len ( args ) == 0 : # we'll allow blank messages to propagate further in case some # other handler cares about them. return None action_keyword = args [ 0 ] args = args [ 1 : ] if not self . location : if len ( args ) == 0 : # todo: this will change when users are tied to locations # though need to make sure that PACK and APPROVE still require location code # (since they refer to locations different from the sender's loc) raise SMSError ( "must specify a location code" ) self . case , self . location = self . get_supply_point_and_location ( args [ 0 ] ) args = args [ 1 : ] action = self . commtrack_settings . action_by_keyword ( action_keyword ) if action : # TODO: support single-action by product, as well as by action? self . verify_location_registration ( ) self . case_id = self . case . case_id _tx = self . single_action_transactions ( action , args ) else : # initial keyword not recognized; delegate to another handler return None return self . unpack_transactions ( _tx )