summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-09-25 14:11:10 -0400
committerGitHub <noreply@github.com>2018-09-25 14:11:10 -0400
commit38f070a5876e91945bfadd3fe60ddcb8b21b96c3 (patch)
tree3a85cc21da32868323060397ff55cf3c0119fa34 /cmd2/cmd2.py
parentc0f283b2dc387c3fec5057370767afe7d8021960 (diff)
parentfcfa8ed840f245ac83287e27e1318b539b678bf8 (diff)
downloadcmd2-git-38f070a5876e91945bfadd3fe60ddcb8b21b96c3.tar.gz
Merge pull request #540 from python-cmd2/delete_deprecated_hooks
Deleted the hook methods which were deprecated in the previous release
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py62
1 files changed, 1 insertions, 61 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 972a2be4..91b84f0d 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1649,58 +1649,6 @@ class Cmd(cmd.Cmd):
"""
return statement
- # ----- Methods which are cmd2-specific lifecycle hooks which are not present in cmd -----
-
- # noinspection PyMethodMayBeStatic
- def preparse(self, raw: str) -> str:
- """Hook method executed before user input is parsed.
-
- WARNING: If it's a multiline command, `preparse()` may not get all the
- user input. _complete_statement() really does two things: a) parse the
- user input, and b) accept more input in case it's a multiline command
- the passed string doesn't have a terminator. `preparse()` is currently
- called before we know whether it's a multiline command, and before we
- know whether the user input includes a termination character.
-
- If you want a reliable pre parsing hook method, register a postparsing
- hook, modify the user input, and then reparse it.
-
- :param raw: raw command line input :return: potentially modified raw command line input
- :return: a potentially modified version of the raw input string
- """
- return raw
-
- # noinspection PyMethodMayBeStatic
- def postparsing_precmd(self, statement: Statement) -> Tuple[bool, Statement]:
- """This runs after parsing the command-line, but before anything else; even before adding cmd to history.
-
- NOTE: This runs before precmd() and prior to any potential output redirection or piping.
-
- If you wish to fatally fail this command and exit the application entirely, set stop = True.
-
- If you wish to just fail this command you can do so by raising an exception:
-
- - raise EmptyStatement - will silently fail and do nothing
- - raise <AnyOtherException> - will fail and print an error message
-
- :param statement: the parsed command-line statement as a Statement object
- :return: (stop, statement) containing a potentially modified version of the statement object
- """
- stop = False
- return stop, statement
-
- # noinspection PyMethodMayBeStatic
- def postparsing_postcmd(self, stop: bool) -> bool:
- """This runs after everything else, including after postcmd().
-
- It even runs when an empty line is entered. Thus, if you need to do something like update the prompt due
- to notifications from a background thread, then this is the method you want to override to do it.
-
- :param stop: True implies the entire application should exit.
- :return: True implies the entire application should exit.
- """
- return stop
-
def parseline(self, line: str) -> Tuple[str, str, str]:
"""Parse the line into a command name and a string containing the arguments.
@@ -1740,9 +1688,6 @@ class Cmd(cmd.Cmd):
data = func(data)
if data.stop:
break
- # postparsing_precmd is deprecated
- if not data.stop:
- (data.stop, data.statement) = self.postparsing_precmd(data.statement)
# unpack the data object
statement = data.statement
stop = data.stop
@@ -1807,9 +1752,7 @@ class Cmd(cmd.Cmd):
data = func(data)
# retrieve the final value of stop, ignoring any
# modifications to the statement
- stop = data.stop
- # postparsing_postcmd is deprecated
- return self.postparsing_postcmd(stop)
+ return data.stop
except Exception as ex:
self.perror(ex)
@@ -1863,9 +1806,6 @@ class Cmd(cmd.Cmd):
pipe runs out. We can't refactor it because we need to retain
backwards compatibility with the standard library version of cmd.
"""
- # preparse() is deprecated, use self.register_postparsing_hook() instead
- line = self.preparse(line)
-
while True:
try:
statement = self.statement_parser.parse(line)