@@ -1649,58 +1649,6 @@ def precmd(self, statement: Statement) -> Statement:
16491649 """
16501650 return statement
16511651
1652- # ----- Methods which are cmd2-specific lifecycle hooks which are not present in cmd -----
1653-
1654- # noinspection PyMethodMayBeStatic
1655- def preparse (self , raw : str ) -> str :
1656- """Hook method executed before user input is parsed.
1657-
1658- WARNING: If it's a multiline command, `preparse()` may not get all the
1659- user input. _complete_statement() really does two things: a) parse the
1660- user input, and b) accept more input in case it's a multiline command
1661- the passed string doesn't have a terminator. `preparse()` is currently
1662- called before we know whether it's a multiline command, and before we
1663- know whether the user input includes a termination character.
1664-
1665- If you want a reliable pre parsing hook method, register a postparsing
1666- hook, modify the user input, and then reparse it.
1667-
1668- :param raw: raw command line input :return: potentially modified raw command line input
1669- :return: a potentially modified version of the raw input string
1670- """
1671- return raw
1672-
1673- # noinspection PyMethodMayBeStatic
1674- def postparsing_precmd (self , statement : Statement ) -> Tuple [bool , Statement ]:
1675- """This runs after parsing the command-line, but before anything else; even before adding cmd to history.
1676-
1677- NOTE: This runs before precmd() and prior to any potential output redirection or piping.
1678-
1679- If you wish to fatally fail this command and exit the application entirely, set stop = True.
1680-
1681- If you wish to just fail this command you can do so by raising an exception:
1682-
1683- - raise EmptyStatement - will silently fail and do nothing
1684- - raise <AnyOtherException> - will fail and print an error message
1685-
1686- :param statement: the parsed command-line statement as a Statement object
1687- :return: (stop, statement) containing a potentially modified version of the statement object
1688- """
1689- stop = False
1690- return stop , statement
1691-
1692- # noinspection PyMethodMayBeStatic
1693- def postparsing_postcmd (self , stop : bool ) -> bool :
1694- """This runs after everything else, including after postcmd().
1695-
1696- It even runs when an empty line is entered. Thus, if you need to do something like update the prompt due
1697- to notifications from a background thread, then this is the method you want to override to do it.
1698-
1699- :param stop: True implies the entire application should exit.
1700- :return: True implies the entire application should exit.
1701- """
1702- return stop
1703-
17041652 def parseline (self , line : str ) -> Tuple [str , str , str ]:
17051653 """Parse the line into a command name and a string containing the arguments.
17061654
@@ -1740,9 +1688,6 @@ def onecmd_plus_hooks(self, line: str) -> bool:
17401688 data = func (data )
17411689 if data .stop :
17421690 break
1743- # postparsing_precmd is deprecated
1744- if not data .stop :
1745- (data .stop , data .statement ) = self .postparsing_precmd (data .statement )
17461691 # unpack the data object
17471692 statement = data .statement
17481693 stop = data .stop
@@ -1807,9 +1752,7 @@ def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement])
18071752 data = func (data )
18081753 # retrieve the final value of stop, ignoring any
18091754 # modifications to the statement
1810- stop = data .stop
1811- # postparsing_postcmd is deprecated
1812- return self .postparsing_postcmd (stop )
1755+ return data .stop
18131756 except Exception as ex :
18141757 self .perror (ex )
18151758
@@ -1863,9 +1806,6 @@ def _complete_statement(self, line: str) -> Statement:
18631806 pipe runs out. We can't refactor it because we need to retain
18641807 backwards compatibility with the standard library version of cmd.
18651808 """
1866- # preparse() is deprecated, use self.register_postparsing_hook() instead
1867- line = self .preparse (line )
1868-
18691809 while True :
18701810 try :
18711811 statement = self .statement_parser .parse (line )
0 commit comments