@@ -626,11 +626,6 @@ def visible_prompt(self) -> str:
626
626
"""
627
627
return ansi .strip_ansi (self .prompt )
628
628
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
-
634
629
def poutput (self , msg : Any , * , end : str = '\n ' ) -> None :
635
630
"""Print message to self.stdout and appends a newline by default
636
631
@@ -744,7 +739,7 @@ def ppaged(self, msg: str, end: str = '\n', chop: bool = False) -> None:
744
739
745
740
# Don't attempt to use a pager that can block if redirecting or running a script (either text or Python)
746
741
# 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 () :
748
743
if ansi .allow_ansi .lower () == ansi .ANSI_NEVER .lower ():
749
744
msg_str = ansi .strip_ansi (msg_str )
750
745
@@ -1606,6 +1601,19 @@ def _autocomplete_default(self, text: str, line: str, begidx: int, endidx: int,
1606
1601
tokens_to_parse = raw_tokens if preserve_quotes else tokens
1607
1602
return completer .complete_command (tokens_to_parse , text , line , begidx , endidx )
1608
1603
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
+
1609
1617
def get_names (self ):
1610
1618
"""Return an alphabetized list of names comprising the attributes of the cmd2 class instance."""
1611
1619
return dir (self )
@@ -3228,7 +3236,7 @@ def do_py(self, args: argparse.Namespace) -> Optional[bool]:
3228
3236
:return: True if running of commands should stop
3229
3237
"""
3230
3238
from .py_bridge import PyBridge
3231
- if self ._in_py :
3239
+ if self .in_pyscript () :
3232
3240
err = "Recursively entering interactive Python consoles is not allowed."
3233
3241
self .perror (err )
3234
3242
return
0 commit comments