@@ -626,11 +626,6 @@ def visible_prompt(self) -> str:
626626 """
627627 return ansi .strip_ansi (self .prompt )
628628
629- @property
630- def aliases (self ) -> Dict [str , str ]:
631- """Read-only property to access the aliases stored in the StatementParser."""
632- return self .statement_parser .aliases
633-
634629 def poutput (self , msg : Any , * , end : str = '\n ' ) -> None :
635630 """Print message to self.stdout and appends a newline by default
636631
@@ -744,7 +739,7 @@ def ppaged(self, msg: str, end: str = '\n', chop: bool = False) -> None:
744739
745740 # Don't attempt to use a pager that can block if redirecting or running a script (either text or Python)
746741 # Also only attempt to use a pager if actually running in a real fully functional terminal
747- if functional_terminal and not self ._redirecting and not self ._in_py and not self ._script_dir :
742+ if functional_terminal and not self ._redirecting and not self .in_pyscript () and not self .in_script () :
748743 if ansi .allow_ansi .lower () == ansi .ANSI_NEVER .lower ():
749744 msg_str = ansi .strip_ansi (msg_str )
750745
@@ -1606,6 +1601,19 @@ def _autocomplete_default(self, text: str, line: str, begidx: int, endidx: int,
16061601 tokens_to_parse = raw_tokens if preserve_quotes else tokens
16071602 return completer .complete_command (tokens_to_parse , text , line , begidx , endidx )
16081603
1604+ def in_script (self ) -> bool :
1605+ """Return whether a text script is running"""
1606+ return self ._current_script_dir is not None
1607+
1608+ def in_pyscript (self ) -> bool :
1609+ """Return whether a pyscript is running"""
1610+ return self ._in_py
1611+
1612+ @property
1613+ def aliases (self ) -> Dict [str , str ]:
1614+ """Read-only property to access the aliases stored in the StatementParser"""
1615+ return self .statement_parser .aliases
1616+
16091617 def get_names (self ):
16101618 """Return an alphabetized list of names comprising the attributes of the cmd2 class instance."""
16111619 return dir (self )
@@ -3228,7 +3236,7 @@ def do_py(self, args: argparse.Namespace) -> Optional[bool]:
32283236 :return: True if running of commands should stop
32293237 """
32303238 from .py_bridge import PyBridge
3231- if self ._in_py :
3239+ if self .in_pyscript () :
32323240 err = "Recursively entering interactive Python consoles is not allowed."
32333241 self .perror (err )
32343242 return
0 commit comments